public async Task <ActionResult> PopulateBranchCollection() { _Connection.DatabaseConnection(); var database = _Connection.GetDatabase(); _Branch.SetDatabase(database); long documentNumber = await database.GetCollection <BranchModel>("Branch").Find(s => true).CountDocumentsAsync(); ViewBag.Message = _Message.GetMessage(1); ViewBag.EmptyCollection = "false"; if (documentNumber == 0) { List <BranchModel> branchModels = new List <BranchModel>(); _KeyId.SetKey(); BranchModel dev = new BranchModel() { Id = _KeyId.GetKey(), Code = "Dev", Description = "Development" }; branchModels.Add(dev); _KeyId.SetKey(); BranchModel qa = new BranchModel() { Id = _KeyId.GetKey(), Code = "Qa", Description = "Quality" }; branchModels.Add(qa); _KeyId.SetKey(); BranchModel prod = new BranchModel() { Id = _KeyId.GetKey(), Code = "Prod", Description = "Production" }; branchModels.Add(prod); _Branch.CreateBranch(branchModels); ViewBag.Message = _Message.GetMessage(3); ViewBag.EmptyCollection = "true"; } List <BranchModel> branches = _Branch.GetBranchModels(); //Obter todos os branch models armazenados na colecção Branch; return(await Task.Run(() => View("PopulateBranchCollection", branches))); }
public async Task <IActionResult> CreateBranch([FromBody] CreateBranchRequest request) { var result = await branchService.CreateBranch(request); return(StatusCode((int)result.Code, result.Value)); }
public IActionResult AddBranch(Branch Branch) { branchService.CreateBranch(Branch); return(Ok()); }