示例#1
0
        public string Put()
        {
            DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>();
            SchedulingDbContext         schDbContext = new SchedulingDbContext(connString);
            string reqType = this.ReadQueryStringData("reqType");
            string str     = this.ReadPostData();

            try
            {
                #region Update Shifts (Manage Shifts)
                if (reqType == "UpdateShift")
                {
                    ShiftsMasterModel shiftData = DanpheJSONConvert.DeserializeObject <ShiftsMasterModel>(str);
                    shiftData.ModifiedOn = System.DateTime.Now;
                    schDbContext.ShiftsMaster.Attach(shiftData);
                    schDbContext.Entry(shiftData).State = EntityState.Modified;
                    schDbContext.Entry(shiftData).Property(x => x.CreatedOn).IsModified = false;
                    schDbContext.Entry(shiftData).Property(x => x.CreatedBy).IsModified = false;
                    schDbContext.SaveChanges();
                    responseData.Status  = "OK";
                    responseData.Results = shiftData;
                }
                #endregion
            }
            catch (Exception ex)
            {
                responseData.Status       = "Failed";
                responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString();
            }

            return(DanpheJSONConvert.SerializeObject(responseData, true));
        }
 public static void UpdateEmpShiftMap(SchedulingDbContext schDbContext, EmployeeShiftMap shiftMap)
 {
     try
     {
         shiftMap.ModifiedOn = System.DateTime.Now;
         schDbContext.EmpShiftMAP.Attach(shiftMap);
         schDbContext.Entry(shiftMap).State = EntityState.Modified;
         schDbContext.Entry(shiftMap).Property(x => x.CreatedOn).IsModified = false;
         schDbContext.Entry(shiftMap).Property(x => x.CreatedBy).IsModified = false;
         schDbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 //here im updating shift master from Manage working hours txn .. as i need following fields(shiftname,starttime,endtime,totalhrs) to get updated, so i have bought only that much content here...
 #region Update Shift Master
 public static void UpdateShiftMaster(SchedulingDbContext schDbContext, ShiftsMasterModel shift)
 {
     try
     {
         shift.ModifiedOn = System.DateTime.Now;
         schDbContext.ShiftsMaster.Attach(shift);
         schDbContext.Entry(shift).Property(x => x.ShiftName).IsModified = true;
         schDbContext.Entry(shift).Property(x => x.StartTime).IsModified = true;
         schDbContext.Entry(shift).Property(x => x.EndTime).IsModified   = true;
         schDbContext.Entry(shift).Property(x => x.TotalHrs).IsModified  = true;
         schDbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static void UpdateEmpSchedules(SchedulingDbContext schDBContext, EmpSchedules schedules)
 {
     try
     {
         schDBContext.EmpSchedules.Attach(schedules);
         schDBContext.Entry(schedules).Property(x => x.IsWorkingDay).IsModified = true;
         schDBContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }