public string CreateNewBranch(BranchModel branchModel) { UserService userService = new UserService(); var status = Enums.UpdateStatus.Failure; var branch = branchModel.branch; var currentUser = ClaimsPrincipal.Current.Identity.Name; var retailer = _unitOfWork.SellerRepository.GetRetailerInfo(currentUser); var store = _unitOfWork.SellerRepository.Find(x => x.StoreId == retailer.StoreId).FirstOrDefault(); if (branchModel.userName == currentUser) { SellerBranch branchDetails = new SellerBranch(); branchDetails.BranchName = branch.BranchName; branchDetails.Email = branch.Email; branchDetails.Address1 = branch.Address1; branchDetails.Address2 = branch.Address2; branchDetails.City = branch.City; branchDetails.PostalCode = branch.PostalCode; branchDetails.PhoneNumber = branch.PhoneNumber; branchDetails.Latitude = branch.Latitude; branchDetails.Longitude = branch.Longitude; branchDetails.Country = branch.Country; branchDetails.State = branch.State; branchDetails.Store = store.StoreId; branchDetails.CreatedOnUtc = DateTime.UtcNow; store.Branches.Add(branchDetails); _unitOfWork.SellerBranchRepository.Add(branchDetails); _unitOfWork.Commit(); status = Enums.UpdateStatus.Success; } return(status.ToString()); }
private void AddSeller(RetailerUserDTO retailerUserDTO, int userid) { try { //Add user as Seller. Seller newSeller = new Seller(); newSeller.StoreName = retailerUserDTO.BusinessName; newSeller.PrimaryContact = userid; newSeller.CreatedOnUtc = DateTime.UtcNow; newSeller.CreatedUser = userid; _unitOfWork.SellerRepository.Add(newSeller); SellerBranch branch = new SellerBranch(); branch.Store = newSeller.StoreId; branch.Address1 = retailerUserDTO.Address1; branch.Address2 = retailerUserDTO.Address2; branch.BranchName = retailerUserDTO.BusinessName; branch.Email = retailerUserDTO.Email; branch.Country = retailerUserDTO.Country; branch.State = retailerUserDTO.State; branch.City = retailerUserDTO.City; branch.PostalCode = retailerUserDTO.Pincode; branch.PhoneNumber = retailerUserDTO.PhoneNumber1; branch.Latitude = retailerUserDTO.Latitude; branch.Longitude = retailerUserDTO.Longitude; branch.CreatedOnUtc = DateTime.UtcNow; newSeller.Branches.Add(branch); _unitOfWork.SellerRepository.Add(newSeller); _unitOfWork.Commit(); } catch { } }