示例#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 AddEmpSchedules(SchedulingDbContext schDBContext, EmpSchedules schedules)
 {
     try
     {
         schDBContext.EmpSchedules.Add(schedules);
         schDBContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public static void EnsureDbSeeded(this SchedulingDbContext context)
        {
            // ensure data is clean
            context.Routes.RemoveRange(context.Routes);
            context.Places.RemoveRange(context.Places);
            context.SaveChanges();

            var unionSt = new Place {
                Id = "Station0118", Name = "Union Street"
            };
            var winchester = new Place {
                Id = "Station0001", Name = "Winchester"
            };

            context.Places.Add(unionSt);
            context.Places.Add(winchester);
            context.SaveChanges();

            var routes = new List <Route>
            {
                new Route
                {
                    Id            = "trl-sthcrs",
                    OriginId      = unionSt.Id,
                    DestinationId = winchester.Id,
                    DepartUtc     = (new DateTime(2018, 09, 01))
                },
                new Route
                {
                    Id            = "sthcrs-trl",
                    OriginId      = winchester.Id,
                    DestinationId = unionSt.Id,
                    DepartUtc     = (new DateTime(2018, 10, 01))
                }
            };


            context.Routes.AddRange(routes);
            context.SaveChanges();
        }
 public static void AddEmpShiftMap(SchedulingDbContext schDbContext, EmployeeShiftMap shiftMap)
 {
     try
     {
         shiftMap.CreatedOn = System.DateTime.Now;
         schDbContext.EmpShiftMAP.Add(shiftMap);
         schDbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static void AddShiftMaster(SchedulingDbContext schDbContext, ShiftsMasterModel shift)
 {
     try
     {
         shift.CreatedOn = System.DateTime.Now;
         schDbContext.ShiftsMaster.Add(shift);
         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;
     }
 }
 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;
     }
 }
示例#9
0
        public string Post()
        {
            DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>();
            SchedulingDbContext         schDbContext = new SchedulingDbContext(connString);
            string reqType = this.ReadQueryStringData("reqType");
            string str     = this.ReadPostData();

            try
            {
                #region Employee Schedule manage : Insert/Update schedules
                if (reqType == "manageEmpSchedules")
                {
                    List <EmpSchedules> schedulesData = DanpheJSONConvert.DeserializeObject <List <EmpSchedules> >(str);

                    Boolean Flag = false;
                    Flag = SchedulingBL.ManageEmpSchedules(schedulesData, schDbContext);
                    if (Flag)
                    {
                        responseData.Status  = "OK";
                        responseData.Results = 1;
                    }
                    else
                    {
                        responseData.ErrorMessage = "check console for error details.";
                        responseData.Status       = "Failed";
                    }
                }
                #endregion
                #region Add Shift (Manage Shifts)
                else if (reqType == "AddShift")
                {
                    ShiftsMasterModel shiftMaster = DanpheJSONConvert.DeserializeObject <ShiftsMasterModel>(str);
                    shiftMaster.CreatedOn = System.DateTime.Now;
                    schDbContext.ShiftsMaster.Add(shiftMaster);
                    schDbContext.SaveChanges();
                    responseData.Status  = "OK";
                    responseData.Results = shiftMaster;
                }
                #endregion
                #region Employee Working Hours manage Transaction
                else if (reqType == "EmpWokringHours")
                {
                    WorkingHoursTxnVM workHrsTxnData = DanpheJSONConvert.DeserializeObject <WorkingHoursTxnVM>(str);

                    Boolean Flag = false;
                    Flag = SchedulingBL.WorkingHrsTxn(workHrsTxnData, schDbContext);
                    if (Flag)
                    {
                        responseData.Status  = "OK";
                        responseData.Results = 1;
                    }
                    else
                    {
                        responseData.ErrorMessage = "check console for error details.";
                        responseData.Status       = "Failed";
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                responseData.Status       = "Failed";
                responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString();
            }

            return(DanpheJSONConvert.SerializeObject(responseData, true));
        }
示例#10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });


            using (var context = new SchedulingDbContext())
            {
                context.Database.EnsureDeleted();//UnComment out this line to recreate the DB
                context.Database.EnsureCreated();

                //Create dummy test Data
                var facility1 = new DataAccess.DataModels.FacilityDataModel()
                {
                    FacilityId   = "123",
                    FacilityName = "test",
                    CreatedBy    = "Me",
                    CreatedOn    = DateTime.Now,
                    ModifiedBy   = "MeToo",
                    ModifiedOn   = DateTime.Now,
                    ResourceId   = Guid.NewGuid(),
                    Status       = DataAccess.DataModels.DataStatus.Active
                };
                context.Facilities.Add(facility1);
                context.Facilities.Add(new DataAccess.DataModels.FacilityDataModel()
                {
                    FacilityId   = "321",
                    FacilityName = "another test",
                    CreatedBy    = "Me",
                    CreatedOn    = DateTime.Now,
                    ModifiedBy   = "MeToo",
                    ModifiedOn   = DateTime.Now,
                    ResourceId   = Guid.NewGuid(),
                    Status       = DataAccess.DataModels.DataStatus.Active
                });
                var bob = new DataAccess.DataModels.TeamMemberDataModel()
                {
                    TeammateName    = "Bob 1",
                    TeammateType    = "Bob",
                    CurrentFacility = facility1,
                    CreatedBy       = "Me",
                    CreatedOn       = DateTime.Now,
                    ModifiedBy      = "MeToo",
                    ModifiedOn      = DateTime.Now,
                    ResourceId      = Guid.NewGuid(),
                    Status          = DataAccess.DataModels.DataStatus.Active
                };
                context.TeamMember.Add(bob);

                context.TeamMember.Add(new DataAccess.DataModels.TeamMemberDataModel()
                {
                    TeammateName    = "Bob 2",
                    TeammateType    = "Bob",
                    CurrentFacility = facility1,
                    CreatedBy       = "Me",
                    CreatedOn       = DateTime.Now,
                    ModifiedBy      = "MeToo",
                    ModifiedOn      = DateTime.Now,
                    ResourceId      = Guid.NewGuid(),
                    Status          = DataAccess.DataModels.DataStatus.Active
                });

                context.TeamMemberDaySchedule.Add(new DataAccess.DataModels.TeamMemberDayScheduleDataModel()
                {
                    Date       = new DateTime(2018, 8, 6),
                    Schedule   = "Never",
                    TeamMember = bob,
                    CreatedBy  = "Me",
                    CreatedOn  = DateTime.Now,
                    ModifiedBy = "MeToo",
                    ModifiedOn = DateTime.Now,
                    ResourceId = Guid.NewGuid(),
                    Status     = DataAccess.DataModels.DataStatus.Active
                });

                context.TeamMemberDaySchedule.Add(new DataAccess.DataModels.TeamMemberDayScheduleDataModel()
                {
                    Date       = new DateTime(2018, 8, 7),
                    Schedule   = "some",
                    TeamMember = bob,
                    CreatedBy  = "Me",
                    CreatedOn  = DateTime.Now,
                    ModifiedBy = "MeToo",
                    ModifiedOn = DateTime.Now,
                    ResourceId = Guid.NewGuid(),
                    Status     = DataAccess.DataModels.DataStatus.Active
                });

                context.TeamMemberDaySchedule.Add(new DataAccess.DataModels.TeamMemberDayScheduleDataModel()
                {
                    Date       = new DateTime(2018, 8, 9),
                    Schedule   = "Off Duty",
                    TeamMember = bob,
                    CreatedBy  = "Me",
                    CreatedOn  = DateTime.Now,
                    ModifiedBy = "MeToo",
                    ModifiedOn = DateTime.Now,
                    ResourceId = Guid.NewGuid(),
                    Status     = DataAccess.DataModels.DataStatus.Active
                });

                context.TeamMemberDaySchedule.Add(new DataAccess.DataModels.TeamMemberDayScheduleDataModel()
                {
                    Date       = new DateTime(2018, 8, 13),
                    Schedule   = "Next Week",
                    TeamMember = bob,
                    CreatedBy  = "Me",
                    CreatedOn  = DateTime.Now,
                    ModifiedBy = "MeToo",
                    ModifiedOn = DateTime.Now,
                    ResourceId = Guid.NewGuid(),
                    Status     = DataAccess.DataModels.DataStatus.Active
                });

                context.SaveChanges();
            }

            // Yes this should be in its own file
            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <FacilityDataModel, FacilityModel>();
            });
        }