• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Model.StationContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中eStationCore.Model.StationContext的典型用法代码示例。如果您正苦于以下问题:C# StationContext类的具体用法?C# StationContext怎么用?C# StationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StationContext类属于eStationCore.Model命名空间,在下文中一共展示了StationContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SaveChat

        /// <summary>
        /// Creer Nouvelle Conversation
        /// </summary>
        /// <param name="newChat"></param>
        /// <returns></returns>
        public bool SaveChat (Chat newChat) {
            using (var db = new StationContext()) {

                if(newChat.Persons.Count < 2)
                    throw new InvalidOperationException("CONVERSATION_MUST_HAVE_AT_LEAST_TWO_PERSONS");

                if(newChat.ChatGuid==Guid.Empty)
                    newChat.ChatGuid=Guid.NewGuid();

                newChat.DateAdded        =DateTime.Now;
                newChat.AddUserGuid      =Guid.Empty;
                newChat.LastEditUserGuid =Guid.Empty;
                newChat.LastEditDate     =DateTime.Now;

                //foreach (var talker in newConversation.Persons)
                //{
                //    if(talker.PersonGuid==Guid.Empty)
                //        talker.PersonGuid=Guid.NewGuid();
                //    db.Set<Person>().Add(talker);
                //}

                foreach(var talk in newChat.Messages.Where(talk => talk.MessageGuid==Guid.Empty))
                    talk.MessageGuid=Guid.NewGuid();
                db.Set<Chat>().Add(newChat);      
                return db.SaveChanges()>0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:32,代码来源:CommManager.cs


示例2: GetPersonDocuments

 /// <summary>
 /// La list des Documents d'une Personne
 /// </summary>
 /// <param name="personGuid"></param>
 /// <param name="maxResult"></param>
 /// <returns></returns>
 public IEnumerable GetPersonDocuments(Guid personGuid, int maxResult = 7)
 {
     using (var db = new StationContext()) {
         return (db.Set<Person>().Find(personGuid).Documents).Select(
                 d => new Document {DocumentGuid = d.DocumentGuid, DocumentName = d.DocumentName, Description = d.Description, FileType = d.FileType }).OrderBy(d=> d.DateAdded);                
     }
 }
开发者ID:HalidCisse,项目名称:eStation,代码行数:13,代码来源:DocumentsManager.cs


示例3: Paycheck

        /// <summary>
        /// Confirmer paiement d'un salaire
        /// </summary>
        /// <param name="payrollGuid"></param>
        /// <param name="finalPaycheck"></param>
        /// <param name="numeroReference"></param>
        /// <param name="totalHoursWorked"></param>
        /// <returns></returns>
        /// <exception cref="InvalidOperationException"></exception>
        public bool Paycheck(Guid payrollGuid, double? finalPaycheck = null, string numeroReference = null, TimeSpan? totalHoursWorked = null)
        {           
            using (var db = new StationContext()) {
                var payroll = db.Payrolls.Find(payrollGuid);
                if(payroll==null)
                    throw new InvalidOperationException("PAYROLL_REFERENCE_NOT_FOUND");
                
                if(payroll.IsPaid)
                    throw new InvalidOperationException("PAYCHECK_ALREADY_PAID");

                if(!string.IsNullOrEmpty(numeroReference) && SalarySlipExist(numeroReference))
                    throw new InvalidOperationException("PAYSLIP_REFERENCE_DUPLICATE");

                if(totalHoursWorked!=null)
                    payroll.HoursWorked = (TimeSpan) totalHoursWorked;

                if(finalPaycheck==null)
                    finalPaycheck=(new PayrollCard(payroll)).TotalSalary;

                payroll.FinalPaycheck    = (double) finalPaycheck;
                payroll.IsPaid           = true;
                payroll.IsPaidTo         = Guid.Empty;
                payroll.DatePaid         = DateTime.Now;
                payroll.NumeroReference  = string.IsNullOrEmpty(numeroReference) ? GetNewSalarySlipRef() : numeroReference;

                payroll.LastEditDate     =DateTime.Now;
                payroll.LastEditUserGuid =Guid.Empty;

                db.Payrolls.Attach(payroll);
                db.Entry(payroll).State=EntityState.Modified;

                return db.SaveChanges()>0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:43,代码来源:PayrollManager.cs


示例4: SaveDocument

 /// <summary>
 /// Represente un enseignant, proff, staff, qui a la possibilite de se connecter a l'Eschool
 /// </summary>
 /// <param name="document"></param>
 /// <returns></returns>
 //[PrincipalPermission(SecurityAction.Demand, Role = Clearances.StaffWrite)]
 public bool SaveDocument (Document document) {                      
     using (var db = new StationContext()) {
         if(document.DocumentGuid==Guid.Empty)
             document.DocumentGuid=Guid.NewGuid();
         
         db.Set<Document>().Add(document);
         return db.SaveChanges()>0;
     }
 }
开发者ID:HalidCisse,项目名称:eStation,代码行数:15,代码来源:DocumentsManager.cs


示例5: Put

        public async Task<bool> Put(Fuel myFuel)
        {
            using (var db = new StationContext())
            {
                myFuel.LastEditDate = DateTime.Now;

                db.Fuels.Attach(myFuel);
                db.Entry(myFuel).State = EntityState.Modified;
                return await db.SaveChangesAsync() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:11,代码来源:FuelManager.cs


示例6: Put

        public bool Put(Pompe myPompe)
        {
            using (var db = new StationContext())
            {
                myPompe.LastEditDate = DateTime.Now;

                db.Pompes.Attach(myPompe);
                db.Entry(myPompe).State = EntityState.Modified;
                return db.SaveChanges() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:11,代码来源:PompesManager.cs


示例7: Put

        public bool Put(Oil myOil)
        {
            using (var db = new StationContext())
            {
                myOil.LastEditDate = DateTime.Now;

                db.Oils.Attach(myOil);
                db.Entry(myOil).State = EntityState.Modified;
                return db.SaveChanges() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:11,代码来源:OilManager.cs


示例8: Post

        public async Task<bool> Post(FuelDelivery fuelDelivery)
        {
            using (var db = new StationContext())
            {
                if (fuelDelivery.FuelDeliveryGuid == Guid.Empty) fuelDelivery.FuelDeliveryGuid = Guid.NewGuid();

                fuelDelivery.DateAdded = DateTime.Now;
                fuelDelivery.LastEditDate = DateTime.Now;

                db.FuelDeliverys.Add(fuelDelivery);
                return await db.SaveChangesAsync() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:13,代码来源:CiternesManager.cs


示例9: UpdateStaff

        public bool UpdateStaff(Staff mStaff)
        {
            using (var db = new StationContext())
            {
                db.Staffs.Attach(mStaff);
                db.Entry(mStaff).State = EntityState.Modified;

                db.Set<Person>().Attach(mStaff.Person);
                db.Entry(mStaff.Person).State = EntityState.Modified;

                return db.SaveChanges() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:13,代码来源:HrManager.cs


示例10: Post

        public bool Post(OilDelivery myDelivery)
        {
            using (var db = new StationContext())
            {
                if (myDelivery.OilDeliveryGuid == Guid.Empty) myDelivery.OilDeliveryGuid = Guid.NewGuid();

                myDelivery.DateAdded = DateTime.Now;
                myDelivery.LastEditDate = DateTime.Now;

                db.OilDeliveries.Add(myDelivery);
                return db.SaveChanges() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:13,代码来源:OilManager.cs


示例11: Delete

        public async Task<bool> Delete(Guid fuelGuid)
        {
            using (var db = new StationContext())
            {
                var myObject = await db.Fuels.FindAsync(fuelGuid);

                if (myObject == null) throw new InvalidOperationException("FUEL_NOT_FOUND");

                myObject.LastEditDate = DateTime.Now;
                myObject.IsDeleted = true;

                db.Fuels.Attach(myObject);
                db.Entry(myObject).State = EntityState.Modified;
                return await db.SaveChangesAsync() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:16,代码来源:FuelManager.cs


示例12: AddStaff

        public async Task<bool> AddStaff(Staff myStaff)
        {
            using (var db = new StationContext())
            {
                if (myStaff.StaffGuid == Guid.Empty)
                    myStaff.StaffGuid = Guid.NewGuid();
                if (myStaff.Person.PersonGuid == Guid.Empty)
                    myStaff.Person.PersonGuid = Guid.NewGuid();

                await myStaff.Person.Validate();

                db.Set<Person>().Add(myStaff.Person);
                db.Staffs.Add(myStaff);
                return await db.SaveChangesAsync() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:16,代码来源:HrManager.cs


示例13: Post

        public bool Post(Pompe myPompe)
        {
            using (var db = new StationContext())
            {
                if (!db.Citernes.Any(f => f.CiterneGuid == myPompe.CiterneGuid))
                    throw new InvalidOperationException("CITERNE_REFERENCE_NOT_FOUND");
                

                if (myPompe.PompeGuid == Guid.Empty) myPompe.PompeGuid = Guid.NewGuid();

                myPompe.DateAdded = DateTime.Now;
                myPompe.LastEditDate = DateTime.Now;

                db.Pompes.Add(myPompe);
                return db.SaveChanges() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:17,代码来源:PompesManager.cs


示例14: UpdateCustomer

        /// <summary>
        /// 
        /// </summary>
        /// <param name="myCustomer"></param>
        /// <returns></returns>
        //[PrincipalPermission(SecurityAction.Demand, Role = SecurityClearances.StaffWrite)]
        public bool UpdateCustomer(Customer myCustomer)
        {
            using (var db = new StationContext())
            {
                // ReSharper disable once PossibleNullReferenceException
                var userTrace = (Guid)Membership.GetUser().ProviderUserKey;                
                myCustomer.LastEditDate = DateTime.Now;
                myCustomer.LastEditUserGuid = userTrace;

                db.Customers.Attach(myCustomer);
                db.Entry(myCustomer).State = EntityState.Modified;

                db.Set<Person>().Attach(myCustomer.Person);
                db.Entry(myCustomer.Person).State = EntityState.Modified;

                return db.SaveChanges() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:24,代码来源:CustomersManager.cs


示例15: CancelTransaction

        /// <summary>
        /// 
        /// </summary>
        /// <param name="transactionGuid"></param>
        /// <returns></returns>
        public bool CancelTransaction(Guid transactionGuid)
        {
            using (var db = new StationContext())
            {
                var theTransaction = db.Transactions.Find(transactionGuid);
                if (theTransaction == null) throw new InvalidOperationException("CAN_NOT_FIND_REFERENCE_TRANSACTION");

                theTransaction.IsDeleted = true;
                theTransaction.DeleteDate = DateTime.Now;
                theTransaction.DeleteUserGuid = Guid.Empty;

                theTransaction.LastEditDate = DateTime.Now;
                theTransaction.LastEditUserGuid = Guid.Empty;

                db.Transactions.Attach(theTransaction);
                db.Entry(theTransaction).State = EntityState.Modified;
                return db.SaveChanges() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:24,代码来源:FinanceManager.cs


示例16: CancelPaycheck

        /// <summary>
        /// Annuler un Paiement d'un salaire
        /// </summary>
        /// <param name="payrollGuid"></param>
        public bool CancelPaycheck (Guid payrollGuid) {
            using (var db = new StationContext()) {
                var payroll = db.Payrolls.Find(payrollGuid);
                if(payroll==null)
                    throw new InvalidOperationException("PAYROLL_REFERENCE_NOT_FOUND");
                
                payroll.IsPaid           =false;
                payroll.IsPaidTo         =Guid.Empty;
                payroll.DatePaid         =DateTime.Now;
                payroll.NumeroReference  = string.Empty;

                payroll.LastEditDate     =DateTime.Now;
                payroll.LastEditUserGuid =Guid.Empty;

                db.Payrolls.Attach(payroll);
                db.Entry(payroll).State=EntityState.Modified;

                return db.SaveChanges()>0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:24,代码来源:PayrollManager.cs


示例17: Post

        public async Task<bool> Post(Fuel myFuel)
        {
            using (var db = new StationContext())
            {              
                if (myFuel.FuelGuid == Guid.Empty) myFuel.FuelGuid = Guid.NewGuid();

                myFuel.DateAdded = DateTime.Now;
                myFuel.LastEditDate = DateTime.Now;

                db.Fuels.Add(myFuel);
                if (!myFuel.Prices.Any()) return db.SaveChanges() > 0;

                if (myFuel.Prices.First().PriceGuid == Guid.Empty) myFuel.Prices.First().PriceGuid = Guid.NewGuid();
                myFuel.Prices.First().ProductGuid = myFuel.FuelGuid;
                myFuel.Prices.First().FromDate = DateTime.Now;
                db.Set<Price>().Add(myFuel.Prices.First());

                return await db.SaveChangesAsync() > 0;
            }
        }        
开发者ID:HalidCisse,项目名称:eStation,代码行数:20,代码来源:FuelManager.cs


示例18: AddCustomer

        /// <summary>
        /// Represente un client
        /// </summary>
        /// <param name="newCustomer"></param>
        /// <exception cref="InvalidOperationException">CAN_NOT_CREAT_STAFF_PROFILE</exception>
        /// <returns></returns>
        //[PrincipalPermission(SecurityAction.Demand, Role = SecurityClearances.CustomerWrite)]
        public bool AddCustomer(Customer newCustomer) 
        {
            Guard.WhenArgument(newCustomer.Person.FullName, "CUSTOMER_NAME_CAN_NOT_BE_EMPTY").IsNullOrEmpty().IsEqual("Inconnue").Throw();

            using (var db = new StationContext())
            {
                if (newCustomer.CustomerGuid == Guid.Empty)
                    newCustomer.CustomerGuid = Guid.NewGuid();
                if (newCustomer.Person.PersonGuid == Guid.Empty)
                    newCustomer.Person.PersonGuid = Guid.NewGuid();

                // ReSharper disable once PossibleNullReferenceException
                var userTrace = (Guid) Membership.GetUser().ProviderUserKey;
                newCustomer.DateAdded = DateTime.Now;
                newCustomer.AddUserGuid = userTrace;
                newCustomer.LastEditDate = DateTime.Now;
                newCustomer.LastEditUserGuid = userTrace;

                db.Set<Person>().Add(newCustomer.Person);
                db.Customers.Add(newCustomer);
                return db.SaveChanges() > 0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:30,代码来源:CustomersManager.cs


示例19: PushChat

        /// <summary>
        /// Envoyer Un Chat
        /// </summary>
        /// <param name="newMessage"></param>
        /// <returns></returns>
        public bool PushChat (Message newMessage) {
            using (var db = new StationContext()) {
                if(db.Set<Person>().Find(newMessage.SenderGuid)==null)
                    throw new InvalidOperationException("SENDER_REFERENCE_NOT_FOUND");
                if(newMessage.MessageGuid==Guid.Empty)
                    newMessage.MessageGuid=Guid.NewGuid();
                if(db.Set<Chat>().Find(newMessage.ChatGuid)==null)
                    throw new InvalidOperationException("CONVERSATION_REFERENCE_NOT_FOUND");

                newMessage.DateAdded        =DateTime.Now;
                newMessage.AddUserGuid      = Guid.Empty;
                newMessage.LastEditUserGuid = Guid.Empty;
                newMessage.LastEditDate     =DateTime.Now;
                
                if (newMessage.Attachement == null) return db.SaveChanges() > 0;

                if(newMessage.Attachement.DocumentGuid==Guid.Empty)
                    newMessage.Attachement.DocumentGuid=Guid.NewGuid();
                db.Set<Document>().Add(newMessage.Attachement);
                db.Set<Message>().Add(newMessage);

                return db.SaveChanges()>0;
            }
        }
开发者ID:HalidCisse,项目名称:eStation,代码行数:29,代码来源:CommManager.cs


示例20: Get

 public async Task<Oil> Get(Guid oilGuid)
 {
     using (var db = new StationContext())
         return await db.Oils.FindAsync(oilGuid);
 }
开发者ID:HalidCisse,项目名称:eStation,代码行数:5,代码来源:OilManager.cs



注:本文中的eStationCore.Model.StationContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DataAccess.DAL类代码示例发布时间:2022-05-26
下一篇:
C# eSARDAL.DCFIEntities类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap