コード例 #1
0
        public ActionResult Entry(BatchCreateVm entity)
        {
            if (ModelState.IsValid)
            {
                var batch   = Mapper.Map <Batch>(entity);
                var batches = _batchManager.GetAllBatches();
                if (batches.FirstOrDefault(x => x.Id == batch.Id) != null)
                {
                    ViewBag.Message = "Exist";
                    entity.OrganizationSelectListItems = GetAllOrganizationSlItems();
                    return(View(entity));
                }
                else
                {
                    bool isAdded = _batchManager.Add(batch);
                    if (isAdded)
                    {
                        ViewBag.Message = "Saved";
                        return(RedirectToAction("Edit", batch));
                    }
                }
            }

            ModelState.AddModelError("", "An Unknown Error Occured!");
            entity.OrganizationSelectListItems = GetAllOrganizationSlItems();
            return(View(entity));
        }