Пример #1
0
        public async Task <IActionResult> AddOrUpdate()
        {
            ShopSchedule schedule = JsonConvert.DeserializeObject <ShopSchedule>(Request.Form["shopSchedule"]);
            await _scheduleService.AddorUpdate(schedule);

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task AddorUpdate(ShopSchedule timings)
        {
            var schedule = _context.ShopSchedule.FirstOrDefault();

            if (schedule != null)
            {
                schedule.DeliveryTimings = timings.DeliveryTimings;

                _context.ShopSchedule.Update(schedule);
                await _context.SaveChangesAsync();
            }
            else
            {
                timings.IsOpen = false;
                await _context.ShopSchedule.AddAsync(timings);

                await _context.SaveChangesAsync();
            }

            await HangfireService(schedule.DeliveryTimings);
        }