Beispiel #1
0
        public void GetDetails_EmptyObjectId_Failure()
        {
            List <ScheduleDetail> oScheduleDetails;

            oScheduleDetails = ScheduleDetail.GetDetails(_mockServer, "");
            Assert.IsTrue(oScheduleDetails.Count == 0, "Static call to GetDetails with empty ObjectId should return empty list");
        }
Beispiel #2
0
        public void GetScheduleDetail_EmptyObjectId_Failure()
        {
            List <ScheduleDetail> oScheduleDetails;
            var res = ScheduleDetail.GetScheduleDetails(_mockServer, "", out oScheduleDetails);

            Assert.IsFalse(res.Success, "Static call to GetScheduleDetails with empty ObjectId did not fail");
        }
Beispiel #3
0
        public async Task <Schedule> AddSchedule([Service] DBAttendanceContext dBAttendanceContext, ScheduleInput input)
        {
            try
            {
                var schedule = new Schedule
                {
                    StartDate      = input.StartDate,
                    FinishDate     = input.FinishDate,
                    EmployeeCardId = input.EmployeeCardId
                };
                input.ScheduleDetail.ForEach(sd =>
                {
                    var scheduleDetail = new ScheduleDetail
                    {
                        Day     = sd.Day,
                        InHour  = sd.InHour,
                        OutHour = sd.OutHour
                    };
                    schedule.ScheduleDetail.Add(scheduleDetail);
                });
                dBAttendanceContext.Schedule.Add(schedule);
                await dBAttendanceContext.SaveChangesAsync();

                return(schedule);
            }
            catch (System.Exception e)
            {
                throw new QueryException(e.Message);
            }
        }
        public void GetScheduleDetailBySchedIdTest1()
        {
            ScheduleDetail schedDetail = schedDetailDAL.GetScheduleDetailBySchedId(1);

            Assert.NotNull(schedDetail);
            Assert.Equal(1, schedDetail.ScheId);
        }
Beispiel #5
0
        public void GetScheduleDetail_NullConnectionServerWithDisplayName_Failure()
        {
            List <ScheduleDetail> oScheduleDetails;
            var res = ScheduleDetail.GetScheduleDetails(null, "ScheduleObjectId", out oScheduleDetails);

            Assert.IsFalse(res.Success, "Static call to GetScheduleDetails with null ConnectionServerRest did not fail");
        }
        public async Task <ActionResult> Save(ScheduleDetailViewModel model)
        {
            using (ScheduleDetailServiceClient client = new ScheduleDetailServiceClient())
            {
                ScheduleDetail obj = new ScheduleDetail()
                {
                    Key = new ScheduleDetailKey()
                    {
                        ScheduleName = model.ScheduleName,
                        ShiftName    = model.ShiftName
                    },
                    Editor     = User.Identity.Name,
                    EditTime   = DateTime.Now,
                    CreateTime = DateTime.Now,
                    Creator    = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(FMMResources.StringResource.ScheduleDetail_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
Beispiel #7
0
        // GET: ScheduleDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ScheduleDetail scheduleDetail = _scheduleDetailService.Find(id);

            if (scheduleDetail == null)
            {
                return(HttpNotFound());
            }
            var skuRepository = _unitOfWork.Repository <SKU>();

            ViewBag.ComponentSKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku", scheduleDetail.ComponentSKUId);
            //var skuRepository = _unitOfWork.Repository<SKU>();
            ViewBag.ParentSKUId = new SelectList(skuRepository.Queryable(), "Id", "Sku", scheduleDetail.ParentSKUId);
            var productionscheduleRepository = _unitOfWork.Repository <ProductionSchedule>();

            ViewBag.ProductionScheduleId = new SelectList(productionscheduleRepository.Queryable(), "Id", "ScheduleNo", scheduleDetail.ProductionScheduleId);
            var shiftRepository = _unitOfWork.Repository <Shift>();

            ViewBag.ShiftId = new SelectList(shiftRepository.Queryable(), "Id", "Name", scheduleDetail.ShiftId);
            var stationRepository = _unitOfWork.Repository <Station>();

            ViewBag.StationId = new SelectList(stationRepository.Queryable(), "Id", "StationNo", scheduleDetail.StationId);
            return(View(scheduleDetail));
        }
 public Tables(Database db)
 {
     Blocks                   = new Blocks(db);
     Config                   = new Config(db);
     ElimsCommitHistory       = new ElimsCommitHistory(db);
     ElimsData                = new ElimsData(db);
     ElimsGameSpecific        = new ElimsGameSpecific(db);
     ElimsGameSpecificHistory = new ElimsGameSpecificHistory(db);
     ElimsResults             = new ElimsResults(db);
     ElimsScores              = new ElimsScores(db);
     ElimsScoresHistory       = new ElimsScoresHistory(db);
     LeagueConfig             = new LeagueConfig(db);
     LeagueHistory            = new LeagueHistory(db);
     LeagueInfo               = new LeagueInfo(db);
     LeagueMeets              = new LeagueMeets(db);
     Match                    = new Match(db);
     MatchSchedule            = new MatchSchedule(db);
     Quals                    = new Quals(db);
     QualsCommitHistory       = new QualsCommitHistory(db);
     QualsData                = new QualsData(db);
     QualsGameSpecific        = new QualsGameSpecific(db);
     QualsGameSpecificHistory = new QualsGameSpecificHistory(db);
     QualsResults             = new QualsResults(db);
     QualsScores              = new QualsScores(db);
     QualsScoresHistory       = new QualsScoresHistory(db);
     ScheduleDetail           = new ScheduleDetail(db);
     ScheduleStation          = new ScheduleStation(db);
     Team        = new Team(db);
     TeamRanking = new TeamRanking(db);
 }
Beispiel #9
0
        // public bool CreateScheduleDetails(List<ScheduleDetail> schedDetails, MySqlConnection conn, MySqlCommand command)
        // {
        //     bool result = false;
        //     if(schedDetails == null || schedDetails.Count == 0)
        //     {
        //         return result;
        //     }

        //     // if(connection.State == System.Data.ConnectionState.Closed)
        //     // {
        //     //     connection.Open();
        //     // }
        //     connection = conn;

        //     query = "insert into SchedulesDetails(sche_id, sched_timeStart, sched_timeEnd, sched_roomSeats) values";
        //     string schedDetailValue;
        //     string timeStart;
        //     string timeEnd;
        //     foreach (ScheduleDetail schedDetail in schedDetails)
        //     {
        //         timeStart = schedDetail.SchedTimeStart.ToString("yyyy/MM/dd HH:mm:ss");
        //         timeEnd = schedDetail.SchedTimeEnd.ToString("yyyy/MM/dd HH:mm:ss");
        //         schedDetailValue = "("+ schedDetail.ScheId +",'"+ timeStart +"','"+ timeEnd +"','"+ schedDetail.SchedRoomSeats +"'),";

        //         query = query + schedDetailValue;
        //     }

        //     query = query.Substring(0, query.Length - 1) + ";";
        //     command.CommandText = query;
        //     if(command.ExecuteNonQuery() > 0)
        //     {
        //         result = true;
        //     }

        //     connection.Close();

        //     return result;
        // }

        public ScheduleDetail GetScheduleDetailBySchedId(int?schedId)
        {
            if (schedId == null)
            {
                return(null);
            }
            if (connection == null)
            {
                connection = DBHelper.OpenConnection();
            }
            if (connection.State == System.Data.ConnectionState.Closed)
            {
                connection.Open();
            }

            query = $"select * from SchedulesDetails where sched_id = " + schedId + ";";
            MySqlCommand   command     = new MySqlCommand(query, connection);
            ScheduleDetail schedDetail = null;

            using (reader = command.ExecuteReader())
            {
                if (reader.Read())
                {
                    schedDetail = GetScheduleDetail(reader);
                }
            }

            connection.Close();

            return(schedDetail);
        }
Beispiel #10
0
        public override T Convert <T, U>(U entity)
        {
            ScheduleDetail scheduledetail = entity as ScheduleDetail;

            if (scheduledetail == null)
            {
                return(default(T));
            }

            BO.ScheduleDetail scheduledetailBO = new BO.ScheduleDetail();
            scheduledetailBO.ID             = scheduledetail.id;
            scheduledetailBO.Name           = scheduledetail.Name;
            scheduledetailBO.dayofWeek      = scheduledetail.DayOfWeek;
            scheduledetailBO.slotStart      = scheduledetail.SlotStart;
            scheduledetailBO.slotEnd        = scheduledetail.SlotEnd;
            scheduledetailBO.slotDate       = scheduledetail.SlotDate;
            scheduledetailBO.scheduleStatus = (BO.GBEnums.ScheduleStatus)scheduledetail.Status;

            if (scheduledetail.IsDeleted.HasValue)
            {
                scheduledetailBO.IsDeleted = scheduledetail.IsDeleted.Value;
            }
            if (scheduledetail.UpdateByUserID.HasValue)
            {
                scheduledetailBO.UpdateByUserID = scheduledetail.UpdateByUserID.Value;
            }

            using (ScheduleRepository sr = new ScheduleRepository(_context))
            {
                scheduledetailBO.Schedule = sr.Convert <BO.Schedule, Schedule>(scheduledetail.Schedule);
            }

            return((T)(object)scheduledetailBO);
        }
        public async Task <ScheduleItemViewModel> GetScheduleItem(int scheduleId)
        {
            ScheduleDetail detail = await _sheduleDataStore.GetItemAsync(scheduleId);

            ScheduleItemViewModel scheduleItemViewModel = AddScheduleItem(detail);

            return(scheduleItemViewModel);
        }
 public void DeleteAllDetails(int?scheduleID)
 {
     foreach (DRScheduleDetail detail in PXSelect <DRScheduleDetail,
                                                   Where <DRScheduleDetail.scheduleID, Equal <Required <DRSchedule.scheduleID> > > > .Select(this, scheduleID))
     {
         ScheduleDetail.Delete(detail);
     }
 }
Beispiel #13
0
        public ActionResult DeleteConfirmed(int id)
        {
            ScheduleDetail scheduleDetail = db.ScheduleDetails.Find(id);

            db.ScheduleDetails.Remove(scheduleDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #14
0
        public IActionResult DeleteConfirmed(int id)
        {
            ScheduleDetail scheduleDetail = _context.ScheduleDetail.Single(m => m.ID == id);

            _context.ScheduleDetail.Remove(scheduleDetail);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void ScheduleDetailTests()
        {
            //cover all lists on the server - there must be at least one
            List <Schedule> oSchedules;
            WebCallResult   res = Schedule.GetSchedules(_connectionServer, out oSchedules);

            Assert.IsTrue(res.Success, "Failed to fetch schedule list:" + res.ToString());

            string strScheduleObjectId = "";

            foreach (var oSchedule in oSchedules)
            {
                if (oSchedule.ScheduleDetails().Count > 0)
                {
                    strScheduleObjectId = oSchedule.ObjectId;
                    break;
                }
            }

            Assert.IsFalse(string.IsNullOrEmpty(strScheduleObjectId), "Failed to find a schedule with at least one detail element");

            List <ScheduleDetail> oScheduleDetails;
            string strScheduleDetailObjectId = "";

            res = ScheduleDetail.GetScheduleDetails(_connectionServer, strScheduleObjectId, out oScheduleDetails);
            Assert.IsTrue(res.Success, "Failed to fetch schedule details from schedule:" + res);

            foreach (var oDetail in oScheduleDetails)
            {
                Console.WriteLine(oDetail.ToString());
                Console.WriteLine(oDetail.DumpAllProps());

                oDetail.IsScheduleDetailActive(DateTime.Now, true);
                oDetail.IsScheduleDetailActive(DateTime.Now, false);

                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(1), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(2), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(3), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(4), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(5), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(6), false);
                strScheduleDetailObjectId = oDetail.ObjectId;
            }

            res = ScheduleDetail.GetScheduleDetails(null, strScheduleObjectId, out oScheduleDetails);
            Assert.IsFalse(res.Success, "Schedule detail fetch with null Connection server should fail");

            try
            {
                ScheduleDetail oScheduleDetail = new ScheduleDetail(_connectionServer, strScheduleObjectId,
                                                                    strScheduleDetailObjectId);
                Console.WriteLine(oScheduleDetail);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false, "Failed to create a ScheduleDetial instance with valid objectIds:" + ex);
            }
        }
Beispiel #16
0
 public RepairSchedule ToRepairSchedule(ScheduleDetail SDetail, Repair repair)
 {
     return(new RepairSchedule
     {
         IsActive = true,
         Schedule = SDetail,
         Repair = repair,
     });
 }
        protected async Task <int> DeleteAllConfigsOfScheduleDetailAsync(ScheduleDetail entity)
        {
            var id  = new SqlParameter("id", entity.Id);
            var sql = $"DELETE FROM {nameof(ScheduleWeekConfig)} WHERE " +
                      $"{nameof(ScheduleWeekConfig.ScheduleDetailId)}=@{id.ParameterName}";
            var result = await context.Database.ExecuteSqlRawAsync(sql, id);

            return(result);
        }
Beispiel #18
0
        public IActionResult DeleteDetailConfirmed(int id)
        {
            ScheduleDetail scheduleDetail = _context.ScheduleDetail.Single(m => m.ID == id);
            int            scheduleID     = scheduleDetail.ScheduleID;

            _context.ScheduleDetail.Remove(scheduleDetail);
            _context.SaveChanges();
            return(RedirectToAction("Edit", new { id = scheduleID }));
        }
        public void InsertScheduleDetail()
        {
            ScheduleDetail beforeScheduleDetail = _scheduleService.InsertScheduleDetail("2826018c-69cc-4ead-946b-70bb5a47ab02", "test1", "value1");

            Assert.IsNotNull(beforeScheduleDetail);

            ScheduleDetail failingScheduleDetail = _scheduleService.InsertScheduleDetail("99", "test2", "value2");

            Assert.IsNull(failingScheduleDetail);
        }
Beispiel #20
0
 public DeleteScheduleViewModel ToDeleteScheduleViewModel(ScheduleDetail scheduleDetail)
 {
     return(new DeleteScheduleViewModel
     {
         ActiveScheduleId = scheduleDetail.ActiveSchedule.Id,
         LicencePLate = scheduleDetail.Vehicle.LicencePlate,
         Dealership = scheduleDetail.Dealership.DealerShipName,
         Service = scheduleDetail.ActiveSchedule.Services.ServiceType,
         ScheduleDay = scheduleDetail.ActiveSchedule.ScheduleDay,
     });
 }
Beispiel #21
0
 public EditScheduleViewModel ToEditScheduleViewModel(ScheduleDetail scheduleDetail, IEnumerable <DealershipService> services)
 {
     return(new EditScheduleViewModel
     {
         LicencePlate = scheduleDetail.Vehicle.LicencePlate,
         Dealership = scheduleDetail.Dealership.DealerShipName,
         ServicesSupliedId = scheduleDetail.ActiveSchedule.Services.Id,
         Services = _comboHelpers.GetServices(services),
         Day = scheduleDetail.ActiveSchedule.ScheduleDay,
         Remarks = scheduleDetail.ActiveSchedule.Remarks,
     });
 }
Beispiel #22
0
        public ScheduleDetail GetScheduleDetail(MySqlDataReader reader)
        {
            int      schedId        = reader.GetInt32("sched_id");
            int      scheId         = reader.GetInt32("sche_id");
            DateTime schedTimeStart = reader.GetDateTime("sched_timeStart");
            DateTime schedTimeEnd   = reader.GetDateTime("sched_timeEnd");
            string   schedRoomSeats = reader.GetString("sched_roomSeats");

            ScheduleDetail scheduleDetail = new ScheduleDetail(schedId, scheId, schedTimeStart, schedTimeEnd, schedRoomSeats);

            return(scheduleDetail);
        }
Beispiel #23
0
        public async Task <Schedule> ModifySchedule([Service] DBAttendanceContext dBAttendanceContext, ScheduleInput input)
        {
            try
            {
                var schedule = await dBAttendanceContext.Schedule.FindAsync(input.Id);

                if (schedule != null)
                {
                    schedule.StartDate  = input.StartDate;
                    schedule.FinishDate = input.FinishDate;
                    schedule.State      = input.State;
                    input.ScheduleDetail.ForEach(sd =>
                    {
                        switch (sd.Action)
                        {
                        case 0:
                            var scheduleDetail = new ScheduleDetail
                            {
                                Day     = sd.Day,
                                InHour  = sd.InHour,
                                OutHour = sd.OutHour
                            };
                            schedule.ScheduleDetail.Add(scheduleDetail);
                            break;

                        case 1:
                            var scheduleDetail1     = schedule.ScheduleDetail.SingleOrDefault(sd1 => sd1.Id == sd.Id);
                            scheduleDetail1.Day     = sd.Day;
                            scheduleDetail1.InHour  = sd.InHour;
                            scheduleDetail1.OutHour = sd.OutHour;
                            break;

                        case 2:
                            var scheduleDetail2 = schedule.ScheduleDetail.SingleOrDefault(sd1 => sd1.Id == sd.Id);
                            schedule.ScheduleDetail.Remove(scheduleDetail2);
                            break;
                        }
                    });
                    await dBAttendanceContext.SaveChangesAsync();

                    return(schedule);
                }
                else
                {
                    throw new QueryException("No se encontró el horario.");
                }
            }
            catch (System.Exception e)
            {
                throw new QueryException(e.Message);
            }
        }
Beispiel #24
0
        public String GetScheduledMinute()
        {
            ScheduleDetail detail = ScheduleItem.ScheduleDetails.SingleOrDefault(sd => sd.Name == "minute");

            if (detail != null)
            {
                return(detail.Value);
            }
            else
            {
                return("0");
            }
        }
Beispiel #25
0
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            ScheduleDetail scheduleDetail = _scheduleDetailService.Find(id);

            _scheduleDetailService.Delete(scheduleDetail);
            _unitOfWork.SaveChanges();
            if (Request.IsAjaxRequest())
            {
                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            DisplaySuccessMessage("Has delete a ScheduleDetail record");
            return(RedirectToAction("Index"));
        }
Beispiel #26
0
 public IActionResult Edit(ScheduleDetail scheduleDetail)
 {
     if (ModelState.IsValid)
     {
         _context.Update(scheduleDetail);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewData["PositionName"] = new SelectList(_context.Position, "PositionName", "Position", scheduleDetail.PositionName);
     ViewData["ScheduleID"]   = new SelectList(_context.Schedule, "ScheduleID", "Schedule", scheduleDetail.ScheduleID);
     ViewData["ShiftName"]    = new SelectList(_context.Shift, "ShiftName", "Shift", scheduleDetail.ShiftName);
     return(View(scheduleDetail));
 }
Beispiel #27
0
        public void ScheduleDetail_Constructor_ErrorResponse_Failure()
        {
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = false,
                ResponseText = "error text",
                StatusCode   = 404
            });
            ScheduleDetail oTest = new ScheduleDetail(_mockServer, "ScheduleObjectId", "ScheduleDetailObjectId");

            Console.WriteLine(oTest);
        }
Beispiel #28
0
 public StartRepairViewModel ToStartRepairViewModel(ScheduleDetail scheduleDetail, IEnumerable <DealershipDepartment> departments)
 {
     return(new StartRepairViewModel
     {
         Dealership = scheduleDetail.Dealership,
         DealershipId = scheduleDetail.Dealership.Id,
         Departments = _comboHelpers.GetDealershipDepartments(departments),
         VehicleId = scheduleDetail.Vehicle.Id,
         Vehicle = scheduleDetail.Vehicle,
         ScheduleId = scheduleDetail.Id,
         Schedule = scheduleDetail.ActiveSchedule,
         ActiveScheduleId = scheduleDetail.ActiveSchedule.Id
     });
 }
Beispiel #29
0
        public async Task <Employee> AddEmployee([Service] DBAttendanceContext dBAttendanceContext, EmployeeInput input)
        {
            try
            {
                var employee = new Employee
                {
                    CardId    = input.CardId,
                    Name      = input.Name,
                    Lastname  = input.Lastname,
                    Genre     = input.Genre,
                    Birthdate = input.BirthDate,
                    Address   = input.Address,
                    Phone     = input.Phone,
                    Email     = input.Email,
                    PhotoName = input.PhotoName
                };
                var contractInput = input.Contract;
                employee.Contract.Add(new Contract
                {
                    StartDate  = contractInput.StartDate,
                    FinishDate = contractInput.FinishDate,
                    Mount      = contractInput.Mount,
                    ExtraHours = contractInput.ExtraHours
                });
                var scheduleInput = input.Schedule;
                var schedule      = new Schedule
                {
                    StartDate  = scheduleInput.StartDate,
                    FinishDate = scheduleInput.FinishDate
                };
                scheduleInput.ScheduleDetail.ForEach(sd =>
                {
                    var scheduleDetail = new ScheduleDetail
                    {
                        Day     = sd.Day,
                        InHour  = sd.InHour,
                        OutHour = sd.OutHour
                    };
                    schedule.ScheduleDetail.Add(scheduleDetail);
                });
                employee.Schedule.Add(schedule);
                await dBAttendanceContext.SaveChangesAsync();

                return(employee);
            }
            catch (System.Exception e)
            {
                throw new QueryException(e.Message);
            }
        }
Beispiel #30
0
 public async Task <ScheduleDetailsViewModel> ToScheduleDetailsViewModelAsync(ScheduleDetail scheduleDetail)
 {
     return(new ScheduleDetailsViewModel
     {
         ActiveScheduleId = scheduleDetail.ActiveSchedule.Id,
         LicencePLate = scheduleDetail.Vehicle.LicencePlate,
         Brand = await _brandRepository.GetBrandNameByIdAsync(scheduleDetail.Vehicle.BrandId),
         Model = await _brandRepository.GetModelNameByIdAsync(scheduleDetail.Vehicle.ModelId),
         Dealership = scheduleDetail.Dealership.DealerShipName,
         Service = scheduleDetail.ActiveSchedule.Services.ServiceType,
         Date = scheduleDetail.ActiveSchedule.ScheduleDay,
         Remarks = scheduleDetail.ActiveSchedule.Remarks,
     });
 }
 public void filterRecord(int length, int masterId, int status, string property, string value, string value2, ref ScheduleDetail[] scheduleDetail)
 {
     int fetch;
     scheduleDetail = null;
     if (property.Equals("FromTime"))
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Time");
         var records = db.ScheduleDetails.Where(a => a.FromTime >= strManipulate.timeValue && a.FromTime <= strManipulate.timeValue2)
                                         .Where(a => a.ScheduleMasterId == masterId)
                                         .Where(a => a.Status == status).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getScheduleDetail = db.ScheduleDetails
                 .Where(a => a.FromTime >= strManipulate.timeValue && a.FromTime <= strManipulate.timeValue2)
                 .Where(a => a.ScheduleMasterId == masterId)
                 .Where(a => a.Status == status)
                 .OrderByDescending(a => a.FromTime).Skip((length)).Take(fetch).ToArray();
             scheduleDetail = getScheduleDetail;
         }
     }
     //ToTime
     else
     {
         StringManipulation strManipulate = new StringManipulation(value, value2, "Time");
         var records = db.ScheduleDetails.Where(a => a.ToTime >= strManipulate.timeValue && a.ToTime <= strManipulate.timeValue2)
                                         .Where(a => a.ScheduleMasterId == masterId)
                                         .Where(a => a.Status == status).Count();
         if (records > length)
         {
             if ((records - length) > pageSize)
                 fetch = pageSize;
             else
                 fetch = records - length;
             var getScheduleDetail = db.ScheduleDetails
                 .Where(a => a.ToTime >= strManipulate.timeValue && a.ToTime <= strManipulate.timeValue2)
                 .Where(a => a.ScheduleMasterId == masterId)
                 .Where(a => a.Status == status)
                 .OrderByDescending(a => a.FromTime).Skip((length)).Take(fetch).ToArray();
             scheduleDetail = getScheduleDetail;
         }
     }
 }
        public IHttpActionResult PutScheduleDetail(int id, ScheduleDetail scheduleDetail)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != scheduleDetail.Id)
            {
                return BadRequest();
            }

            db.Entry(scheduleDetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ScheduleDetailExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
 public IHttpActionResult GetScheduleDetails(int length, int masterId, int status, string property, string value, string value2)
 {
     ScheduleDetail[] scheduleDetail = new ScheduleDetail[pageSize];
     this.filterRecord(length, masterId, status, property, value, value2, ref scheduleDetail);
     if (scheduleDetail != null)
         return Ok(scheduleDetail);
     else
         return Ok();
 }
Beispiel #34
0
 public void AddToScheduleDetails(ScheduleDetail scheduleDetail)
 {
     base.AddObject("ScheduleDetails", scheduleDetail);
 }
Beispiel #35
0
 public static ScheduleDetail CreateScheduleDetail(int id, int userID)
 {
     ScheduleDetail scheduleDetail = new ScheduleDetail();
     scheduleDetail.ID = id;
     scheduleDetail.UserID = userID;
     return scheduleDetail;
 }
        public IHttpActionResult PostScheduleDetail(ScheduleDetail scheduleDetail)
        {
            int scheduleMasterStatus = 0;
            response.status = "FAILURE";
            if (!ModelState.IsValid)
            {
                response.message = "Bad request.";
                return Ok(response);
            }

            try
            {
                if (validateForSave(scheduleDetail.ScheduleMasterId, scheduleDetail.FromTime, scheduleDetail.ToTime))
                {
                    //save scheduleDetail
                    saveScheduleDetail(scheduleDetail, "dummy");
                    //Update schedule master if closed/open
                    ScheduleMaster.updateScheduleMasterStatus(scheduleDetail.ScheduleMasterId, ref scheduleMasterStatus);
                    ScheduleMaster scheduleMaster = db.ScheduleMasters.Find(scheduleDetail.ScheduleMasterId);
                    response.status = "SUCCESS";
                    response.objParam1 = scheduleDetail;
                    response.intParam1 = scheduleMasterStatus;
                }
                else
                    response.message = "Time scheduled is conflict to other schedule.";

            }
            catch (Exception e)
            {
                response.message = e.InnerException.InnerException.Message.ToString();
            }

            return Ok(response);
        }
 public void saveScheduleDetail(ScheduleDetail scheduleDetail, string dummy)
 {
     db.ScheduleDetails.Add(scheduleDetail);
     db.SaveChanges();
 }