public IActionResult Save(BranchModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(RedirectToAction("Index"));
                }

                if (string.IsNullOrEmpty(model.BranchId))
                {
                    model.DateCreated = DateTime.UtcNow;
                    _branchService.Create(model);
                }
                else
                {
                    _branchService.Update(model);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message + " " + ex.InnerException);
            }
            return(Content("Internal server error please contact the system administrator"));
        }
 public IActionResult Create(BranchModel model)
 {
     if (ModelState.IsValid)
     {
         var entity = new Branch()
         {
             BranchName = model.BranchName
         };
         _branchService.Create(entity);
         return(RedirectToAction("BranchList"));
     }
     return(View(model));
 }
Exemple #3
0
        public ActionResult Create(BranchModel model)
        {
            try
            {
                var msg = new MessageModel();
                model.CreatedBy  = AccountIsAuthenticated();
                model.ModifiedBy = AccountIsAuthenticated();
                msg = _branchService.Create(model);

                ViewBag.message = Globals.ErrorMessage(msg.message, msg.result);
                return(View());
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(View());
        }
Exemple #4
0
        public async Task <IActionResult> Create([FromBody] BranchModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            var branch    = _mapper.Map <Branch>(model);
            int companyId = int.Parse(HttpContext.User.Claims.Where(c => c.Type == ClaimTypes.NameIdentifier).FirstOrDefault().Value);
            var result    = await _branchService.Create(branch, companyId);

            if (!result.Success)
            {
                return(BadRequest(new { Success = false, Message = result.Message }));
            }
            var branchmodel = _mapper.Map <BranchModel>(result._branch);

            return(Ok(new { Success = true, result = branchmodel }));
        }
Exemple #5
0
 public ActionResult Create(Branch request)
 {
     _branchService.Create(request);
     _branchService.AssignDealers(request.Id, request.DealerIds);
     return(RedirectToAction(Request.Form["View"], EntityType.Branch.ToString()));
 }
Exemple #6
0
 public override StorePurchaseResponse Execute(StorePurchaseRequest request)
 {
     _branchService.Create();
     return(_next.Execute(request));
 }
Exemple #7
0
 public CreateResponse Post(BranchRequest request)
 {
     return(_branchService.Create(request));
 }
Exemple #8
0
 public async Task Add(SqlBranch branch)
 {
     await _branchService.Create(branch);
 }
Exemple #9
0
 public async Task Add(BranchDTO branchDto)
 {
     var branch = _mapper.Map <Branch>(branchDto);
     await _branchService.Create(branch);
 }