예제 #1
0
 public IActionResult Edit(CampBatch model)
 {
     if (ModelState.IsValid)
     {
         model.UserUpdatedId = User.GetUserId();
         Svc.CampBatches.Update(model);
         Svc.Commit();
         return(RedirectToAction("Index"));
     }
     ViewBag.Camps = new SelectList(Svc.Camps.Items.OrderBy(x => x.CampCategoryId), "Id", "Name", model.CampId);
     return(View(model));
 }
예제 #2
0
        public IActionResult Create(CampBatch model)
        {
            if (ModelState.IsValid)
            {
                Svc.CreateCampBatch(model);
                Svc.Commit();
                return(RedirectToAction("Index"));
            }

            ViewBag.Camps = new SelectList(Svc.Camps.Items.OrderBy(x => x.CampCategoryId), "Id", "Name", model.CampId);
            return(View(model));
        }
예제 #3
0
        public ResultSvc <CampBatch> CreateCampBatch(CampBatch campBatch)
        {
            var result = new ResultSvc <CampBatch>(campBatch);

            try
            {
                if (!CampBatches.Items.Any(x => x.Batch == campBatch.Batch && x.CampId == campBatch.CampId && x.From == campBatch.From && x.To == campBatch.To))
                {
                    campBatch.UserCreatedId = Context.HttpContext.User.GetUserId();
                    CampBatches.Add(campBatch);
                }
                else
                {
                    result.Errors.Add("Tento turnus ve stejném datu již existuje!");
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e.Message);
            }
            return(result);
        }