public ActionResult Create(SlotCreate model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.DayOfWeekNum = BuildDayOfWeekDropdown(model.DayOfWeekNum);
                return(View(model));
            }

            if (TimeSpan.Compare(model.Time, TimeSpan.Zero) < 0 || TimeSpan.Compare(model.Time, new TimeSpan(23, 59, 59)) > 0)
            {
                ModelState.AddModelError("", "Please enter Time using a 24-hour clock in the format HH:MM");
                ViewBag.DayOfWeekNum = BuildDayOfWeekDropdown(model.DayOfWeekNum);
                return(View(model));
            }

            var service = CreateTimeSlotService();

            if (service.GetTimeSlotByDayTime(model.DayOfWeekNum, model.Time).SlotId != 0)
            {
                ModelState.AddModelError("", "This Time Slot already exists. Please enter a different day or time");
                ViewBag.DayOfWeekNum = BuildDayOfWeekDropdown(model.DayOfWeekNum);
                return(View(model));
            }

            if (service.CreateTimeSlot(model))
            {
                TempData["SaveResult"] = $"'{((DayOfWeek)model.DayOfWeekNum).ToString()} at {model.Time}' was created";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", $"'{((DayOfWeek)model.DayOfWeekNum).ToString()} at {model.Time}' could not be created.");
            ViewBag.DayOfWeekNum = BuildDayOfWeekDropdown(model.DayOfWeekNum);
            return(View(model));
        }
        public IHttpActionResult Post(SlotCreate slot)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateSlotService();

            if (!service.CreateSlot(slot))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Example #3
0
        public bool CreateSlot(SlotCreate model)
        {
            var entity =
                new Slot()
            {
                UserId    = _userId,
                SlotId    = model.SlotId,  //model.TimeSlot?
                SlotStart = model.SlotStart,
                SlotEnd   = model.SlotEnd
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Slots.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Example #4
0
        public bool CreateTimeSlot(SlotCreate model)
        {
            var entity =
                new TimeSlot()
            {
                DayOfWeekNum = model.DayOfWeekNum,
                Time         = model.Time,
                MaxPerSlot   = model.MaxPerSlot,
                CreateBy     = _userId,
                CreateAt     = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.TimeSlots.Add(entity);

                bool success = true;
                try { ctx.SaveChanges(); }
                catch { success = false; }

                return(success);
            }
        }
Example #5
0
    //팀 캐릭터 배치 정보 저장
    public void SettingCheck()
    {
        for (int j = 0; j < 2; j++)
        {
            int slotCount = AllSlot[j].Count;
            vec2.Add(new List <Vector2>());
            chaList.Add(new List <string>());
            for (int i = 0; i < slotCount; i++)
            {
                // 그 슬롯의 스크립트를 가져온다.
                Slot slot = AllSlot[j][i].GetComponent <Slot>();

                // 슬롯이 차있으면 저장
                if (slot.isSlots())
                {
                    vec2[j].Add(new Vector2(slot.xloc, slot.yloc));
                    chaList[j].Add(slot.cha);
                    //TeamLv.Add(slot.lv);
                }
            }
        }
        Iv = GameObject.Find("Inventory" + 1).GetComponent <Inventory>();
        Manage_creatslot = GameObject.Find("SlotManager").GetComponent <SlotCreate>();
    }