コード例 #1
0
ファイル: SchedulingController.cs プロジェクト: XenaMac/MTC
        public ActionResult RemoveCustomSchedule(int id)
        {
            using (MTCDbContext db = new MTCDbContext())
            {
                var response = new TransactionResult();
                try
                {
                    BeatCustomSchedule beatCustomSchedules = db.BeatCustomSchedules.Find(id);
                    if (beatCustomSchedules != null)
                    {
                        db.BeatCustomSchedules.Remove(beatCustomSchedules);
                        db.SaveChanges();
                    }

                    response.HasError = false;
                    response.Message  = String.Empty;
                }
                catch (Exception ex)
                {
                    response.HasError = true;
                    response.Message  = ex.InnerException.Message;
                }

                return(Json(response, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
ファイル: SchedulingController.cs プロジェクト: XenaMac/MTC
        public ActionResult SaveCustomSchedule(int?id, int customScheduleId, Guid beatId, int numberOfTrucks)
        {
            using (MTCDbContext db = new MTCDbContext())
            {
                BeatCustomSchedule bhs = null;
                var isNew = false;
                if (id > 0)
                {
                    bhs            = db.BeatCustomSchedules.Find(id);
                    bhs.ModifiedBy = HttpContext.User.Identity.Name;
                    bhs.ModifiedOn = DateTime.Now;
                }
                else
                {
                    bhs            = new BeatCustomSchedule();
                    bhs.CreatedBy  = HttpContext.User.Identity.Name;
                    bhs.ModifiedBy = HttpContext.User.Identity.Name;
                    bhs.CreatedOn  = DateTime.Now;
                    bhs.ModifiedOn = DateTime.Now;
                    isNew          = true;
                }

                bhs.BeatId           = beatId;
                bhs.CustomScheduleId = customScheduleId;
                bhs.NumberOfTrucks   = numberOfTrucks;

                if (isNew)
                {
                    db.BeatCustomSchedules.Add(bhs);
                }

                db.SaveChanges();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }