public void UpdateBranch(BranchDto branchDto, long restaurantAdminId) { ValidateBranch(branchDto, restaurantAdminId); var branch = _branchService.Find(branchDto.BranchId); if (branch == null) { throw new NotFoundException(ErrorCodes.BranchNotFound); } foreach (var branchTitle in branchDto.BranchTitleDictionary) { var branchTranslation = branch.BranchTranslations.FirstOrDefault(x => x.Language.ToLower() == branchTitle.Key.ToLower()); if (branchTranslation == null) { branch.BranchTranslations.Add(new BranchTranslation { Language = branchTitle.Key.ToLower(), BranchTitle = branchTitle.Value, BranchAddress = branchDto.BranchAddressDictionary[branchTitle.Key] }); } else { branchTranslation.BranchTitle = branchTitle.Value; branchTranslation.BranchAddress = branchDto.BranchAddressDictionary[branchTitle.Key]; } } _branchService.Update(branch); SaveChanges(); }
public ActionResult BranchChartData(int?companyId) { BranchDto dto = new BranchDto() { CompanyName = "21st Century Salvage", BranchRecords = new List <BranchRecord>() { new BranchRecord() { BranchName = "B052", PreviousYearRevenue = 0, CurrentYearRevenue = 0, }, new BranchRecord() { BranchName = "B057", PreviousYearRevenue = 7595, CurrentYearRevenue = 65602, }, new BranchRecord() { BranchName = "B063", PreviousYearRevenue = 0, CurrentYearRevenue = 0, }, new BranchRecord() { BranchName = "B068", PreviousYearRevenue = 0, CurrentYearRevenue = 10205, }, new BranchRecord() { BranchName = "B087", PreviousYearRevenue = 0, CurrentYearRevenue = 0, }, new BranchRecord() { BranchName = "B089", PreviousYearRevenue = 0, CurrentYearRevenue = 0, }, new BranchRecord() { BranchName = "B301", PreviousYearRevenue = 0, CurrentYearRevenue = 0, }, new BranchRecord() { BranchName = "B307", PreviousYearRevenue = 0, CurrentYearRevenue = 0, }, new BranchRecord() { BranchName = "B309", PreviousYearRevenue = 0, CurrentYearRevenue = 0, }, new BranchRecord() { BranchName = "B339", PreviousYearRevenue = 249260, CurrentYearRevenue = 240060, }, new BranchRecord() { BranchName = "Other", PreviousYearRevenue = 0, CurrentYearRevenue = 0, }, new BranchRecord() { BranchName = "0", PreviousYearRevenue = 0, CurrentYearRevenue = 0, }, } }; return(Json(dto)); }
// Matrixnet public async Task <ResultObject> CreateBranchFromExcelAsync(string path, BranchDto branchDto) { ResultObject resultObject = new ResultObject(); var branch = _mapper.Map <Branch>(branchDto); branch.UserBranches.Add(new UserBranches() { BranchId = branch.ID, UserId = ConstUserIDs.Administrator }); System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); using (var stream = File.Open(path, FileMode.Open, FileAccess.Read)) { using (var reader = ExcelReaderFactory.CreateReader(stream)) { do { while (reader.Read()) //Each ROW { for (int column = 0; column < reader.FieldCount; column++) { //Console.WriteLine(reader.GetString(column));//Will blow up if the value is decimal etc. Console.WriteLine(reader.GetValue(column));//Get Value returns object } } } while (reader.NextResult()); //Move to NEXT SHEET } } resultObject.Result = branchDto; return(resultObject); }
public async Task <ResultObject> CreateBranchAsync(BranchDto branchDto) { ResultObject resultObject = new ResultObject(); //var resultObject = await _accountService.GetBankAccountAmountAsync(0, branchDto.BDN); //if (resultObject.ServerErrors.Count > 0) // return resultObject; //resultObject.ServerErrors = null; //decimal bdnAmount = resultObject.Result == null ? 0 : (decimal)resultObject.Result; var branch = _mapper.Map <Branch>(branchDto); branch.UserBranches.Add(new UserBranches() { BranchId = branch.ID, UserId = ConstUserIDs.Administrator }); SetZoneIdForBranch(ref branchDto, ref branch); await _branchService.CreateBranchAsync(branch); var rsult = await _transactionManager.SaveAllAsync(); resultObject.Result = branchDto; return(resultObject); }
private void ValidateBranch(BranchDto branchDto, long restaurantAdminId) { foreach (var branchTitle in branchDto.BranchTitleDictionary) { if (string.IsNullOrEmpty(branchTitle.Value)) { throw new ValidationException(ErrorCodes.EmptyBranchTitle); } if (branchTitle.Value.Length > 300) { throw new ValidationException(ErrorCodes.BranchTiteExceedLength); } if (_branchTranslationService.CheckBranchTitleExist(branchTitle.Value, branchTitle.Key, branchDto.BranchId, restaurantAdminId) ) { throw new ValidationException(ErrorCodes.BranchTitleAlreadyExist); } } foreach (var branchAddress in branchDto.BranchAddressDictionary) { if (string.IsNullOrEmpty(branchAddress.Value)) { throw new ValidationException(ErrorCodes.EmptyBranchAddress); } if (branchAddress.Value.Length > 300) { throw new ValidationException(ErrorCodes.BranchAddressExceedLength); } } }
public void AddBranch(BranchDto branchDto, long restaurantAdminId) { var restaurant = _restaurantService.GetRestaurantByAdminId(restaurantAdminId); if (restaurant == null) { throw new NotFoundException(ErrorCodes.RestaurantNotFound); } if (restaurant.IsDeleted) { throw new ValidationException(ErrorCodes.RestaurantDeleted); } ValidateBranch(branchDto, restaurantAdminId); var branch = Mapper.Map <Branch>(branchDto); branch.RestaurantId = restaurant.RestaurantId; foreach (var branchTitle in branchDto.BranchTitleDictionary) { branch.BranchTranslations.Add(new BranchTranslation { BranchTitle = branchTitle.Value, BranchAddress = branchDto.BranchAddressDictionary[branchTitle.Key], Language = branchTitle.Key.ToLower() }); } _branchTranslationService.InsertRange(branch.BranchTranslations); _branchService.Insert(branch); SaveChanges(); }
public bool UpdateBranch(BranchDto newBranchDetails) { var oldBranchDetails = FindBranchById(newBranchDetails.BranchId); var updatedBranchDetails = newBranchDetails.DtoToEntity(); updatedBranchDetails.BranchID = newBranchDetails.BranchId; updatedBranchDetails.DateUpdated = System.DateTime.Now; updatedBranchDetails.CreatedBy = oldBranchDetails.CreatedBy; updatedBranchDetails.CreatedDate = oldBranchDetails.CreatedDate; //updatedBranchDetails = new Branch() //{ // CreatedBy = oldBranchDetails.CreatedBy, // CreatedDate = oldBranchDetails.CreatedDate, // BranchID = newBranchDetails.BranchId //}; //BranchName = newBranchDetails.BranchName.ToUpper(), // BranchAddress = newBranchDetails.BranchAddress, // BranchDetails = newBranchDetails.BranchDetails, // UpdatedBy = newBranchDetails.UpdatedBy, // DateUpdated = System.DateTime.Now, if (this._branch.Update2(updatedBranchDetails).IsNull()) { return(false); } return(true); }
public async Task <IList <BranchDto> > GetBranchesAsync(string projectId) { await _commonValidator.ProjectHaveToExists(projectId); var branchesNames = await _fileSystemService.GetBranchesNamesAsync(projectId); var branches = new List <BranchDto>(); foreach (var branchName in branchesNames) { try { string mkDocsYaml = await _fileSystemService.ReadTextAsync(projectId, branchName, "mkdocs.yml"); var branch = new BranchDto { Name = branchName, MkDocsYaml = mkDocsYaml }; branches.Add(branch); } catch (FileNotFoundException) { _logger.LogWarning($"Branch '{branchName}' in project '{projectId}' doesn't have mkdocs file."); } } branches = branches.OrderBy(x => x.Name).ToList(); return(branches); }
private ResultDto InsertUpdateBranchMaster(BranchDto branchDto) { ResultDto resultDto = new ResultDto(); string obectName = "branch"; try { ObjectParameter prmBranchId = new ObjectParameter("BranchID", branchDto.BranchID); ObjectParameter prmBranchCode = new ObjectParameter("BranchCode", string.Empty); int effectedRow = _dbContext.uspBranchInsertUpdate(prmBranchId, branchDto.BranchName, branchDto.TEBranchName, branchDto.StartDate, branchDto.Phone, branchDto.Email, branchDto.Address, branchDto.AccountantID, branchDto.AccountantFromDate, branchDto.ManagerID, branchDto.ManagerFromDate, branchDto.UserID, prmBranchCode); resultDto.ObjectId = (int)prmBranchId.Value; resultDto.ObjectCode = string.IsNullOrEmpty((string)prmBranchCode.Value) ? branchDto.BranchCode : (string)prmBranchCode.Value; if (resultDto.ObjectId > 0) { resultDto.Message = string.Format("{0} details saved successfully with code : {1}", obectName, resultDto.ObjectCode); } else if (resultDto.ObjectId == -1) { resultDto.Message = string.Format("Error occured while generating {0} code", obectName); } else { resultDto.Message = string.Format("Error occured while saving {0} details", obectName); } } catch (Exception) { resultDto.Message = string.Format("Service layer error occured while saving the {0} details", obectName); resultDto.ObjectId = -98; } return(resultDto); }
public async Task <ContentResult> CreateOrUpdateBranch(BranchDto branchDto) { ReturnMessage returnmessage = new ReturnMessage(1, "Branch Saved Succesfully"); try { var branch = await Task.Run(() => _unitOfWork.Branchs.GetAsync(filter: w => w.Id == branchDto.Id)); var branchToAdd = _mapper.Map <Branch>(branchDto); if (branch.Count() == 0) { branchToAdd.Id = 0; _unitOfWork.Branchs.Add(branchToAdd); } else { _unitOfWork.Branchs.Update(branchToAdd); } var status = _unitOfWork.Complete(); _logger.LogInformation("Log:Add Branch for ID: {Id}", branchToAdd.Id); return(this.Content(returnmessage.returnMessage(null), "application/json")); } catch (Exception ex) { returnmessage.msg = ex.Message.ToString(); returnmessage.msgCode = -3; return(this.Content(returnmessage.returnMessage(null))); } }
public async Task <HttpResponseMessage> Post(string projectId, BranchDto branch) { AssertIfServiceNotAlive(); RestClient <BranchDto> baseClient = GetRestClient(projectId); return(await baseClient.Post(branch)); }
public BranchDto GetByID(int branchId) { var objuspBranchGetByIdResult = _dbContext.uspBranchGetById(branchId).ToList().FirstOrDefault(); BranchDto objBranchDto = AutoMapperEntityConfiguration.Cast <BranchDto>(objuspBranchGetByIdResult); return(objBranchDto); }
private async Task UpdateAsync(BranchDto input) { if (input.Id != null) { var branch = await _branchRepository.FirstOrDefaultAsync((int)input.Id); ObjectMapper.Map(input, branch); } }
public ActionResult PointRateSetup(BranchDto branchDto) { var targetBranch = db.Branches.ToList().FirstOrDefault(); targetBranch.PointRate = branchDto.PointRate; targetBranch.SetModifiedData(User.Identity.GetUserId()); db.SaveChanges(); ViewBag.UserId = User.Identity.GetUserId(); return(RedirectToAction("PointRateSetup")); }
public bool SaveBranch(BranchDto branchDetails) { this.branch = branchDetails.DtoToEntity(); if (this._branch.Insert(this.branch).IsNull()) { return(false); } return(true); }
public async Task <ResultObject> CreateBranchFromExcelAsync([FromBody] BranchDto branchDto) { if (branchDto.ID == 0) { return(await branchAppService.CreateBranchFromExcelAsync(@"", branchDto)); } return(new ResultObject { Result = branchDto, ServerErrors = null }); }
public void Update(BranchDto branchData) { var branchObject = UnitOfWork.BranchRepository.Get(branchData.Id); if (branchObject != null) { branchObject.Name = branchData.Name; } UnitOfWork.SaveChanges(); }
public async Task <ResultObject> UpdateAsync(BranchDto branchDto) { var branch = await branchAppService.UpdateBranchAsync(branchDto); var resultobject = new ResultObject { Result = branch, ServerErrors = null }; return(resultobject); }
public static int NewBranch(BranchDto branchDto) { Branch branch = AutoMapperConfiguration.mapper.Map <Branch>(branchDto); using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities()) { branch = placementDepartmentDB.Branch.Add(branch); placementDepartmentDB.SaveChanges(); return(branch.Id); } }
public HttpResponseMessage EditBranch(Index index) { var branches = _context.Branches.SingleOrDefault(c => c.Id == index.Id); var branchDto = new BranchDto() { Address = branches.Address, Name = branches.Name }; return(Request.CreateResponse(HttpStatusCode.OK, branchDto)); }
public static void editBranch(BranchDto branchDto) { Branch branch = AutoMapperConfiguration.mapper.Map <Branch>(branchDto); using (placementDepartmentDBEntities placementDepartmentDB = new placementDepartmentDBEntities()) { placementDepartmentDB.Branch.Attach(branch); placementDepartmentDB.Entry(branch).State = EntityState.Modified; placementDepartmentDB.SaveChanges(); } }
private async Task CreateBranchAsync(string projectId, string branchName, byte[] content) { string mkdocsContent = Encoding.UTF8.GetString(content); var branch = new BranchDto { Name = branchName, MkDocsYaml = mkdocsContent }; await _branchService.CreateBranchAsync(projectId, branch); }
public async Task CreateOrUpdateBranch(BranchDto input) { if (input.Id == null) { await CreateAsync(input); } else { await UpdateAsync(input); } }
public ActionResult NewTask(long projectId) { BranchDto[] branches; try { branches = _apiService.GetBranches(projectId); } catch (Exception) { branches = new BranchDto[0]; } if (branches.Length == 0) { return(PartialView(new CreateTaskViewModel { ProjectId = projectId, Branches = new List <SelectListItem>() })); } var latestScannedId = branches .Where(_ => _.LastScanFinishedUtc != null) .OrderByDescending(_ => _.LastScanFinishedUtc) .Select(_ => _.Id) .FirstOrDefault(); var model = new CreateTaskViewModel { ProjectId = projectId, Branches = branches.Select(_ => new SelectListItem { Value = _.Id, Text = _.Name, Selected = _.Id == latestScannedId }).ToArray() }; if (model.Branches.Any(_ => _.Selected)) { return(PartialView(model)); } var defaultBranchId = branches.FirstOrDefault(_ => _.IsDefault); if (defaultBranchId != null) { model.Branches.Where(_ => _.Value == defaultBranchId.Id).ForEach(_ => _.Selected = true); } return(PartialView(model)); }
public async Task UpdateBranchAsync(string projectId, string branchName, BranchDto branch) { await _commonValidator.ProjectHaveToExists(projectId); await _commonValidator.BranchHaveToExists(projectId, branchName); if (!IsYamlFileCorrect(branch.MkDocsYaml)) { throw new MkDocsFileIsIncorrectException($"MkDocs file is empty or has incorrect format."); } await _fileSystemService.WriteTextAsync(projectId, branchName, "mkdocs.yml", branch.MkDocsYaml); }
public async Task <IActionResult> Post(string projectId, [FromBody] BranchDto branch) { var authorization = await _authorizationService.AuthorizeAsync(User, new ProjectDto { Id = projectId }, Operations.Update); if (!authorization.Succeeded) { return(Forbid()); } await _branchesService.CreateBranchAsync(projectId, branch); return(Created($"/projects/{projectId}/branches/{branch.Name}", branch)); }
public async Task CreateBranchAsync(string projectId, BranchDto branch) { var result = await _branchesClient.Post(projectId, branch); if (!result.IsSuccessStatusCode) { var content = await result.Content.ReadAsStringAsync(); throw new CreateBranchException("During creating the new branch error occurs: " + content); } _cacheService.ClearBranchesCache(projectId); }
public async Task <IActionResult> Put(string projectId, string branchName, [FromBody] BranchDto branch) { var authorization = await _authorizationService.AuthorizeAsync(User, new ProjectDto { Id = projectId }, Operations.Update); if (!authorization.Succeeded) { return(Forbid()); } await _branchesService.UpdateBranchAsync(projectId, branchName, branch); return(Ok()); }
public HttpResponseMessage GetBranch([FromUri] int branchId) { try { Branch branch = BranchManager.GetBranch(branchId, Branch.Includes.Address | Branch.Includes.BranchType | Branch.Includes.ActivityHours | Branch.Includes.Rules | Branch.Includes.Institution); BranchDto branchDto = Converters.Convert(branch); return(Request.CreateResponse(HttpStatusCode.OK, branchDto)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"failed to get branch {branchId},{ex.Message}")); } }
public async Task <BranchDto> UpdateBranchAsync(BranchDto branchDto) { var branch = _mapper.Map <Branch>(branchDto); SetZoneIdForBranch(ref branchDto, ref branch); var branchTask = await _branchService.UpdateBranchAsync(branch); await _transactionManager.SaveAllAsync(); var finalBranchDto = _mapper.Map <BranchDto>(branchTask); return(finalBranchDto); }
/// <summary> /// Deletes branch over branch contract client. /// </summary> /// <param name="dto">Branch dto which has to be deleted.</param> public void DeleteBranch(BranchDto dto) { _bcc.DeleteBranch(dto); }
/// <summary> /// Inserts branch over branch contract client. /// </summary> /// <param name="dto">Branch dto which has to be inserted.</param> public void InsertBranch(BranchDto dto) { _bcc.InsertBranch(dto); }
/// <summary> /// Updates branch over branch contract client. /// </summary> /// <param name="dto">Branch dto which has to be updated.</param> public void UpdateBranch(BranchDto dto) { _bcc.UpdateBranch(dto); }
public TreeViewItem(BranchDto branchDto, String text) { this.ID = branchDto.Id; this.ParentID = branchDto.NodeParent; this.Text = text; }