Exemple #1
0
 public HttpResponseMessage Add(BranchVM branchVM, string token)
 {
     try
     {
         //check token info
         var isAllow = iAccountService.IsTokenAvailable(token);
         if (!isAllow)
         {
             return(PostResponseFail(HttpStatusCode.ExpectationFailed, ExceptionMessageConstant.TokenNotAvailable));
         }
         //proceed request
         var tokenizedUserId = iAccountService.GetUserIdByToken(token);
         branchVM.UserId = tokenizedUserId;
         iBranchService.AddBranch(branchVM);
         return(PostResponseSuccess(HttpStatusCode.OK, SucessMessageConstant.RequestHandleSuccessful));
     }
     catch (NullReferenceException)
     {
         return(PostResponseFail(HttpStatusCode.ExpectationFailed, ExceptionMessageConstant.RequestNullExceptionMassge));
     }
     catch (Exception ex)
     {
         return(PostResponseFail(HttpStatusCode.ExpectationFailed, ex.Message));
     }
 }
Exemple #2
0
 public IActionResult BranchCreated(Branch branch)
 {
     if (!ModelState.IsValid)
     {
         ModelState.AddModelError(string.Empty, "Something went wrong");
         ViewBag.Stores = _storeService.GetAllStores();
         return(View("CreateBranch"));
     }
     _branchService.AddBranch(branch);
     return(View());
 }
 public ActionResult AddBranch(AddBranchDetails model)
 {
     if (!ModelState.IsValid || _branchService.BranchExist(model.OrganisationId, model.Name) ||
         _branchService.BranchCodeExist(model.OrganisationId, model.Code ?? 0)) return View(model);
     _branchService.AddBranch(model.OrganisationId,new BranchBO
     {
         Name = model.Name,
         Code = model.Code ?? 0
     });
     return RedirectToAction("OrganisationBranchesList",new { organisationId = model.OrganisationId });
 }
Exemple #4
0
 public IActionResult Branch([FromBody] MvBranch branch)
 {
     try
     {
         string branchId = branchService.AddBranch(branch);
         return Ok(branchId);
     }
     catch (Exception ex)
     {
         return BadRequest(ex.Message);
     }
 }
        public ActionResult Create([Bind(Include = "BranchName,BranchLocation,BranchDescription")] Branch branch)
        {
            if (ModelState.IsValid)
            {
                if (_branchService.AddBranch(branch))
                {
                    return(RedirectToAction("Index"));
                }
            }

            return(View(branch));
        }
 public IActionResult Create(Branch branch)
 {
     try
     {
         var newBranch = _branchService.AddBranch(branch);
         return(CreatedAtRoute("GetBranchById", new { id = newBranch.ID }, newBranch));
     }
     catch (Exception)
     {
         return(BadRequest("Branch not found"));
     }
 }
        public async Task <ActionResult> AddNewBranch(BranchReceivingDTO branchReceiving)
        {
            var response = await _branchService.AddBranch(branchReceiving);

            if (response.StatusCode >= 400)
            {
                return(StatusCode(response.StatusCode, response));
            }
            var branch = ((ApiOkResponse)response).Result;

            return(Ok((BranchTransferDTO)branch));
        }
        public async Task <IActionResult> AddBranch(AddBranchParameters enterpriseBranch)
        {
            if (ModelState.IsValid)
            {
                var temp = await branchService.AddBranch(enterpriseBranch);

                if (temp != null)
                {
                    return(Ok(temp));
                }
                else
                {
                    return(BadRequest(new { Message = "Something went wrong. Please, try again later." }));
                }
            }
            else
            {
                return(BadRequest(new { Message = "Invalid parameters supplied." }));
            }
        }
Exemple #9
0
        public IBranch AddBranch <T>(ITree tree, string name, bool follow = false) where T : IBranch
        {
            IBranch branch;

            if (tree.CurrentBranch == null)
            {
                branch = _branchConstructor.Construct <T>(name, null);
                tree.Branches.Add(branch);
            }
            else
            {
                branch = _branchService.AddBranch <T>(tree.CurrentBranch, name);
            }

            if (follow)
            {
                tree.CurrentBranch = branch;
            }

            return(branch);
        }