Ejemplo n.º 1
0
        public async Task <IActionResult> Create(OperatorViewModel model)
        {
            if (ManagedYearPlan == null)
            {
                return(ActionIfNotChoosedManagedYearPlan());
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }

            Operator @operator = new Operator()
            {
                FirstName   = model.FirstName,
                LastName    = model.LastName,
                ArimrNumber = model.ArimrNumber,
                YearPlan    = ManagedYearPlan,
            };
            await _operatorRepository.Add(@operator);

            TempData["message"] = "Nowa osoba została dodana";
            ModelState.Clear();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public bool Add(Operator item)
 {
     if (_operatorRepository.GetSingleById(item.Id) == null && !_operatorRepository.Exists(m => m.Name.Trim().ToUpper() == item.Name.ToUpper()))
     {
         item.CreatedDate = DateTime.Now;
         _operatorRepository.Add(item);
     }
     return(true);
 }