public bool Add(Branch entity) { if (_repository.IsShortNameUnique(entity)) { return(_repository.Add(entity)); } throw new Exception("ShortName is Not Unique!"); }
public ActionResult Create([Bind(Include = "Id,BranchName,BranchAddress,BranchCity,BranchPinCode")] Branch branch) { if (ModelState.IsValid) { //db.Branches.Add(branch); //db.SaveChanges(); db.Add(branch); return(RedirectToAction("Index")); } return(View(branch)); }
private BranchModel Create(BranchModel item) { var data = item.ConvertToData(); using (_unitOfWorkFactory.Create()) { _repository.Add(data); } return(data.ConvertToModel()); }
public CreateResponse Create(BranchRequest request) { try { var branch = TypeAdapter.Adapt <Branch>(request); _branchValidator.ValidateAndThrowException(branch, "Base,Create"); _branchRepository.Add(branch); return(new CreateResponse(branch.Id)); } catch (DataAccessException) { throw new ApplicationException(); } }
public ActionResult Create(Branch branch) { try { if (branch.IsValid) { branchRepository.Add(branch); return(RedirectToActionPermanent("List")); } } catch (Exception ex) { ViewBag.Error = ex.Message; } return(View(branch)); }
public async Task <IActionResult> CreateBranch([FromBody] SaveBranchResource branchResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var branch = mapper.Map <SaveBranchResource, Branch>(branchResource); branch.LastUpdate = DateTime.Now; repository.Add(branch); await unitOfWork.CompleteAsync(); branch = await repository.GetBranch(branch.Id); var result = mapper.Map <Branch, BranchResource>(branch); return(Ok(result)); }
public IActionResult Create(BranchCreateViewModel model) { if (ModelState.IsValid) { string uniqueFileName = ProcessUploadedFile(model); Branch newBranch = new Branch { Name = model.Name, City = model.City, Address = model.Address, PhoneNumber = model.PhoneNumber, BranchStatus = model.BranchStatus, PhotoPath = uniqueFileName }; _branchRepository.Add(newBranch); return(RedirectToAction("index", "home")); } return(View()); }
public bool Add(Branch entity) { return(_repository.Add(entity)); }
public Branch Add(Branch branch) { return(_branchRepository.Add(branch)); }
public void CreateBranch(Branch branch) { branchRepository.Add(branch); }
public void Add(BranchInput input) { branchRepo.Add(input.Name); }
public IActionResult Create(Branch branch) { db.Add(branch); return(RedirectToAction("Index")); }
public IActionResult AddBranch([FromBody] Branch model) { bra_repo.Add(model); return(new OkObjectResult(new { BranchID = model.BranchId })); }