当前位置: 首页>>代码示例>>C#>>正文


C# StationContext.Entry方法代码示例

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


在下文中一共展示了StationContext.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例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(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

示例7: 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

示例8: 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

示例9: CancelSalary

        /// <summary>
        /// Modifier les information d'un salaire
        /// </summary>
        /// <param name="salary"></param>
        /// <exception cref="NotImplementedException"></exception>
        public bool CancelSalary(Salary salary)
        {
            if (string.IsNullOrEmpty(salary.Designation)) throw new InvalidOperationException("DESIGNATION_CAN_NOT_BE_EMPTY");
            if (salary.StartDate > salary.EndDate) throw new InvalidOperationException("START_DATE_SUPERIOR_TO_END_DATE");
            if (salary.EndDate < DateTime.Today)   throw new InvalidOperationException("END_DATE_CAN_NOT_BE_LESS_THAN_TODAY");

            Employment emp;
            using (var db = new StationContext()) emp = db.Employments.Find(salary.EmploymentGuid);
            if (emp == null) throw new InvalidOperationException("EMPLOYEMENT_REFERENCE_NOT_FOUND");
            if ((salary.StartDate < emp.StartDate) || (salary.EndDate > emp.EndDate)) throw new InvalidOperationException("DATES_CAN_NOT_BE_OUT_OF_EMPLOYMENT_BOUNDRIES");

            using (var db = new StationContext())
            {
                var newSalary = db.Salaries.Find(salary.SalaryGuid);
                if (newSalary == null) throw new InvalidOperationException("SALARY_REFERENCE_NOT_FOUND");

                newSalary.EndDate      = salary.EndDate;
                newSalary.Description  = salary.Description;

                var user = Membership.GetUser();
                if (user == null) throw new SecurityException("USER_CAN_NOT_DETERMINED");

                // ReSharper disable once PossibleNullReferenceException
                newSalary.LastEditUserGuid = (Guid)user.ProviderUserKey;
                newSalary.LastEditDate = DateTime.Now;

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

示例10: ChangePrice

        public async Task<bool> ChangePrice(Guid oilGuid, double newPrice)
        {
            using (var db = new StationContext())
            {
                var myOil = db.Oils.Find(oilGuid);

                myOil.CurrentUnitPrice = newPrice;
                myOil.LastPriceUpdate = DateTime.Now;

                myOil.LastEditDate = DateTime.Now;

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

示例11: DeletePrelevement

        public async Task<bool> DeletePrelevement(Guid oilPrelevementGuid)
        {
            using (var db = new StationContext())
            {
                var myObject = await db.OilPrelevements.FindAsync(oilPrelevementGuid);

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

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

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

示例12: DeleteStaff

        public bool DeleteStaff(Guid staffGuid)
        {
            using (var db = new StationContext())
            {
                var theMan = db.Staffs.Find(staffGuid);

                if (theMan == null)
                    throw new InvalidOperationException("CAN_NOT_FIND_STAFF_REFERENCE");

                theMan.Person.DeleteDate = DateTime.Now;
                theMan.Person.IsDeleted = true;
                theMan.Person.DeleteUserGuid = Guid.Empty;

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

示例13: 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

示例14: DeleteChat

 /// <summary>
 /// Supprimer un chat
 /// </summary>
 /// <param name="chatGuid"></param>
 /// <returns></returns>
 public bool DeleteChat (Guid chatGuid) {
     using (var db = new StationContext()) {
         var oldConversation = db.Set<Chat>().Find(chatGuid);
         oldConversation.IsDeleted=true;
         oldConversation.DeleteUserGuid=Guid.Empty;
         db.Set<Chat>().Attach(oldConversation);
         db.Entry(oldConversation).State=EntityState.Modified;
         return db.SaveChanges()>0;
     }
 }
开发者ID:HalidCisse,项目名称:eStation,代码行数:15,代码来源:CommManager.cs

示例15: GetMessage

 /// <summary>
 /// 
 /// </summary>
 /// <param name="messageGuid"></param>
 /// <param name="markRead"></param>
 /// <returns></returns>
 public Conversation GetMessage(Guid messageGuid, bool markRead = true)
 {
     using (var db = new StationContext())
     {              
         var oldMessage = db.Conversations.Find(messageGuid);
         if (oldMessage == null) return null;
        
         oldMessage.IsRead=true;
         oldMessage.LastEditDate=DateTime.Now;
         db.Conversations.Attach(oldMessage);
         db.Entry(oldMessage).State=EntityState.Modified;
         db.SaveChanges();
         return oldMessage;
     }
 }
开发者ID:HalidCisse,项目名称:eStation,代码行数:21,代码来源:CommManager.cs


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