public ApiResponseModel AddCompany(MasterCompany data) { var response = new ApiResponseModel(); _uow.OpenConnection(base.SQLDBConn); var CompanyRepository = new MasterCompanyRepository(_uow); try { data.CompanyID = Helper.GeneratedID(Convert.ToInt32(_uow.GetAppSettings("LengthRandomString")), "COMP"); data.IsActive = true; _uow.BeginTransaction(); CompanyRepository.Insert(data); _uow.CommitTransaction(); response.Message = "Company has been registered successfully"; response.Result = data; return(response); } catch { _uow.RollbackTransaction(); throw; } finally { _uow.Dispose(); } }
public void Update(MasterCompanyDto entity) { //use automapper var saveModel = new MasterCompany { Id = entity.Id, NAME = entity.NAME, ACID = entity.ACID, ADDRESS = entity.ADDRESS, EMAIL = entity.EMAIL, FAX = entity.FAX, FBDATE = entity.FBDATE, FBDATE_BS = entity.FBDATE_BS, FEDATE = entity.FEDATE, FEDATE_BS = entity.FEDATE_BS, WEBSITE = entity.WEBSITE, ISBRANCH = entity.ISBRANCH, PhiscalID = entity.PhiscalID, TELA = entity.TELA, VAT = entity.VAT }; _repository.Update(saveModel); _uow.Commit(); }
public void AddCompany(AddCompanyViewModel model) { try { if (model != null) { MasterCompany entity = new MasterCompany(); entity.CompanyName = model.CompanyName; entity.CompanyAddress = model.CompanyAddress; entity.CompanyLogo = model.CmpLogo; entity.CountryRowID = model.CountryRowID; entity.StateRowID = model.StateRowID; entity.DistrictRowID = model.DistrictRowID; entity.LocationRowID = model.LocationRowID; entity.GeneralEmail = model.GeneralEmail; entity.MobileNo = model.MobileNo; entity.PhoneNo = model.PhoneNo; entity.FaxNo = model.FaxNo; entity.BillingEmail = model.BillingEmail; entity.BillingDName = model.BillingDName; entity.InitiationEmail = model.InitiationEmail; entity.InitiationDName = model.InitiationDisplay; entity.InsuffDName = model.InsuffDName; entity.InsuffEmail = model.InsuffEmail; entity.ReportEmail = model.ReportEmail; entity.ReportDName = model.ReportDName; entity.MISDName = model.MISDName; entity.MISEmail = model.MISEmail; entity.OtherDName = model.OtherDName; entity.OtherEmail = model.OtherEmail; entity.BillingEmail = model.BillingEmail; entity.SMTPServer = model.SMTPServer; entity.SMTPPort = model.Port; entity.SMTPUserName = model.SMTPUserName; entity.SMTPPassword = model.SMTPPassword; entity.EnableSsl = Convert.ToByte(model.EnableSsl); entity.Status = model.Status; db.MasterCompanies.Add(entity); } else { throw new Exception("Company could not be blank!"); } } catch (Exception) { throw; } }
public IActionResult UpdateCompany(MasterCompany data) { try { var response = _Company.UpdateCompany(data); return(ApiResponse(ResponseMessageEnum.Success, response)); } catch (Exception ex) { return(ApiResponse(ResponseMessageEnum.InternalServerError, new ApiResponseModel() { Message = GlobalErrorMessage })); } }
public ApiResponseModel UpdateCompany(MasterCompany data) { var response = new ApiResponseModel(); _uow.OpenConnection(base.SQLDBConn); var CompanyRepository = new MasterCompanyRepository(_uow); var currentData = new MasterCompany(); try { currentData = CompanyRepository.GetSingleData(new MasterCompany { CompanyID = data.CompanyID }); currentData.CompanyName = data.CompanyName; currentData.IsVerified = data.IsVerified; currentData.ModifiedDate = DateTime.Now; _uow.BeginTransaction(); CompanyRepository.Update(currentData); _uow.CommitTransaction(); response.Message = "Company has been updated successfully"; response.Result = currentData; return(response); } catch { _uow.RollbackTransaction(); throw; } finally { _uow.Dispose(); } }
public ApiResponseModel DeleteCompany(string CompanyID) { var response = new ApiResponseModel(); _uow.OpenConnection(base.SQLDBConn); var CompanyRepository = new MasterCompanyRepository(_uow); var currentData = new MasterCompany(); try { currentData = CompanyRepository.GetSingleData(new MasterCompany { CompanyID = CompanyID }); currentData.IsActive = false; _uow.BeginTransaction(); CompanyRepository.Update(currentData); _uow.CommitTransaction(); response.Message = "Company has been deleted successfully"; response.Result = currentData; return(response); } catch { _uow.RollbackTransaction(); throw; } finally { _uow.Dispose(); } }