コード例 #1
0
 public bool Add(Branch entity)
 {
     if (_repository.IsShortNameUnique(entity))
     {
         return(_repository.Add(entity));
     }
     throw new Exception("ShortName is Not Unique!");
 }
コード例 #2
0
        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));
        }
コード例 #3
0
        private BranchModel Create(BranchModel item)
        {
            var data = item.ConvertToData();

            using (_unitOfWorkFactory.Create())
            {
                _repository.Add(data);
            }


            return(data.ConvertToModel());
        }
コード例 #4
0
 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();
     }
 }
コード例 #5
0
 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));
 }
コード例 #6
0
        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));
        }
コード例 #7
0
        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());
        }
コード例 #8
0
 public bool Add(Branch entity)
 {
     return(_repository.Add(entity));
 }
コード例 #9
0
 public Branch Add(Branch branch)
 {
     return(_branchRepository.Add(branch));
 }
コード例 #10
0
 public void CreateBranch(Branch branch)
 {
     branchRepository.Add(branch);
 }
コード例 #11
0
 public void Add(BranchInput input)
 {
     branchRepo.Add(input.Name);
 }
コード例 #12
0
 public IActionResult Create(Branch branch)
 {
     db.Add(branch);
     return(RedirectToAction("Index"));
 }
コード例 #13
0
ファイル: SetupController.cs プロジェクト: wasaya2/ERP-Core
 public IActionResult AddBranch([FromBody] Branch model)
 {
     bra_repo.Add(model);
     return(new OkObjectResult(new { BranchID = model.BranchId }));
 }