public async Task <VmUserItem> ValidateUser(VM_Sys_User_Sign_In user) { var dbresult = await repo.GetUser(user.UserName, Md5.Encrypt(user.Password)); if (dbresult == null) { return(new VmUserItem()); } else { var result = new VmUserItem(); Copy <Com.BudgetMetal.DBEntities.User, VmUserItem>(dbresult, result); if (dbresult.UserRoles != null) { var SelectedRoles = new List <VmRoleItem>(); foreach (var dbItem in dbresult.UserRoles) { var resultUserRoles = new VmRoleItem(); var dbRole = await roleRepo.Get(dbItem.Role_Id); Copy <Com.BudgetMetal.DBEntities.Role, VmRoleItem>(dbRole, resultUserRoles); SelectedRoles.Add(resultUserRoles); } result.SelectedRoles = SelectedRoles; } var resultCompany = new VmCompanyItem(); Copy <Com.BudgetMetal.DBEntities.Company, VmCompanyItem>(dbresult.Company, resultCompany); result.Company = resultCompany; return(result); } }
public async Task <VmGenericServiceResult> Update(VmCompanyItem vmCompanyItem) { VmGenericServiceResult result = new VmGenericServiceResult(); try { Com.BudgetMetal.DBEntities.Company r = await repo.Get(vmCompanyItem.Id); Copy <VmCompanyItem, Com.BudgetMetal.DBEntities.Company>(vmCompanyItem, r); if (r.UpdatedBy.IsNullOrEmpty()) { r.UpdatedBy = "System"; } r.IsVerified = vmCompanyItem.IsVerified; repo.Update(r); repo.Commit(); result.IsSuccess = true; } catch (Exception e) { result.IsSuccess = false; result.Error = e; } return(result); }
public async Task <VmCompanyPage> GetCompanySupplierList(string keyword, int page, int totalRecords) { var dbPageResult = await repo.GetSupplierList(keyword, (page == 0 ? Constants.app_firstPage : page), (totalRecords == 0 ? Constants.app_totalRecords : totalRecords)); if (dbPageResult == null) { return(new VmCompanyPage()); } var resultObj = new VmCompanyPage(); resultObj.RequestId = DateTime.Now.ToString("yyyyMMddHHmmss"); resultObj.RequestDate = DateTime.Now; resultObj.Result = new PageResult <VmCompanyItem>(); resultObj.Result.Records = new List <VmCompanyItem>(); Copy <PageResult <Com.BudgetMetal.DBEntities.Company>, PageResult <VmCompanyItem> >(dbPageResult, resultObj.Result, new string[] { "Records" }); foreach (var dbItem in dbPageResult.Records) { var resultItem = new VmCompanyItem(); Copy <Com.BudgetMetal.DBEntities.Company, VmCompanyItem>(dbItem, resultItem); resultItem.IsVerified = (dbItem.IsVerified == null) ? false : (bool)dbItem.IsVerified; resultObj.Result.Records.Add(resultItem); } return(resultObj); }
public async Task <VmDocumentItem> GetDocumentById(int Id) { var dbPageResult = await documentRepo.Get(Id); if (dbPageResult == null) { return(new VmDocumentItem()); } var resultObj = new VmDocumentItem(); Copy <Com.BudgetMetal.DBEntities.Document, VmDocumentItem>(dbPageResult, resultObj); var dbCodeTableList = await codeTableRepo.GetAll(); if (dbCodeTableList == null) { return(resultObj); } resultObj.DocumentStatusList = new List <VmCodeTableItem>(); resultObj.DocumentTypeList = new List <VmCodeTableItem>(); foreach (var dbcat in dbCodeTableList) { VmCodeTableItem documentStatusandType = new VmCodeTableItem() { Id = dbcat.Id, Name = dbcat.Name }; resultObj.DocumentStatusList.Add(documentStatusandType); resultObj.DocumentTypeList.Add(documentStatusandType); } var dbCompanyList = await companyRepo.GetAll(); if (dbCompanyList == null) { return(resultObj); } resultObj.CompanyList = new List <VmCompanyItem>(); foreach (var dbcat in dbCompanyList) { VmCompanyItem company = new VmCompanyItem() { Id = dbcat.Id, Name = dbcat.Name }; resultObj.CompanyList.Add(company); } return(resultObj); }
// GET: Suppliers/Details/5 public async Task <IActionResult> Details(int id) { VmCompanyItem item = await svs.GetCompanyById(id); if (item == null) { return(NotFound()); } return(View(item)); }
public async Task <IActionResult> Create(VmCompanyItem codeCompanyItem) { var result = svs.Insert(codeCompanyItem); if (result.IsSuccess) { return(RedirectToAction(nameof(Index))); } else { return(View(codeCompanyItem)); } }
public async Task <List <VmCompanyItem> > GetActiveCompanies() { var dbResult = await repo.GetAll(); var resultList = new List <VmCompanyItem>(); foreach (var dbItem in dbResult) { var resultItem = new VmCompanyItem(); Copy <Com.BudgetMetal.DBEntities.Company, VmCompanyItem>(dbItem, resultItem); resultList.Add(resultItem); } return(resultList); }
public async Task <VmDocumentItem> GetFormObject() { VmDocumentItem resultObj = new VmDocumentItem(); var dbCodeTableList = await codeTableRepo.GetAll(); if (dbCodeTableList == null) { return(resultObj); } resultObj.DocumentStatusList = new List <VmCodeTableItem>(); resultObj.DocumentTypeList = new List <VmCodeTableItem>(); foreach (var dbcat in dbCodeTableList) { VmCodeTableItem documentStatusandType = new VmCodeTableItem() { Id = dbcat.Id, Name = dbcat.Name }; resultObj.DocumentStatusList.Add(documentStatusandType); resultObj.DocumentTypeList.Add(documentStatusandType); } var dbCompanyList = await companyRepo.GetAll(); if (dbCompanyList == null) { return(resultObj); } resultObj.CompanyList = new List <VmCompanyItem>(); foreach (var dbcat in dbCompanyList) { VmCompanyItem company = new VmCompanyItem() { Id = dbcat.Id, Name = dbcat.Name }; resultObj.CompanyList.Add(company); } return(resultObj); }
public async Task <VmCompanyItem> GetCompanyByUEN(string RegNo) { var dbPageResult = await repo.GetCompanyByUEN(RegNo); if (dbPageResult == null) { return(new VmCompanyItem()); } var resultObj = new VmCompanyItem(); Copy <Com.BudgetMetal.DBEntities.Company, VmCompanyItem>(dbPageResult, resultObj); return(resultObj); }
public VmGenericServiceResult Insert(VmCompanyItem vmItem) { VmGenericServiceResult result = new VmGenericServiceResult(); try { Com.BudgetMetal.DBEntities.Company r = new Com.BudgetMetal.DBEntities.Company(); Copy <VmCompanyItem, Com.BudgetMetal.DBEntities.Company>(vmItem, r); r.IsVerified = false; r.AwardedQuotation = 0; r.SubmittedQuotation = 0; r.BuyerAvgRating = 0; r.SupplierAvgRating = 0; //Max Default RFQ Per Week var codeTableRepo = this.codeTableRepo.Get(10100001); int maxQuotationPerWeek = Convert.ToInt32(codeTableRepo.Result.Value); //Max Default Quote Per Week codeTableRepo = this.codeTableRepo.Get(10100002); int maxRFQPerWeek = Convert.ToInt32(codeTableRepo.Result.Value); r.MaxQuotationPerWeek = maxQuotationPerWeek; r.MaxRFQPerWeek = maxRFQPerWeek; if (r.CreatedBy.IsNullOrEmpty()) { r.CreatedBy = r.UpdatedBy = "System"; } repo.Add(r); repo.Commit(); result.IsSuccess = true; } catch (Exception e) { result.IsSuccess = false; result.Error = e; } return(result); }
// GET: Companies/Edit/5 public async Task <ActionResult> Edit(int id) { if (id == null) { return(NotFound()); } int _id = (int)id; VmCompanyItem rItem = await svs.GetCompanyById(_id); if (rItem == null) { return(NotFound()); } return(View(rItem)); }
public async Task <IActionResult> Edit(int id, VmCompanyItem companyItem) { if (id != companyItem.Id) { return(NotFound()); } var result = await svs.Update(companyItem); if (result.IsSuccess) { return(RedirectToAction(nameof(Index))); } else { return(View(companyItem)); } }
// GET: Companies/Details/5 public async Task <IActionResult> Profile() { int id = Convert.ToInt32(HttpContext.Session.GetString("Company_Id")); var User_Id = HttpContext.Session.GetString("User_Id"); var userRoles = JsonConvert.DeserializeObject <List <BudgetMetal.ViewModels.Role.VmRoleItem> >(HttpContext.Session.GetString("SelectedRoles")); bool isCompanyAdmin = false; if (userRoles.Where(e => e.Id == Constants.C_Admin_Role).ToList().Count > 0) { isCompanyAdmin = true; } ViewData["isAdmin"] = isCompanyAdmin; VmCompanyItem item = await svs.GetCompanyProfileById(id); if (item == null) { return(NotFound()); } return(View(item)); }
public async Task <VmCompanyPage> GetSupplierByServiceTagsId(int companyId, string serviceTagsId, int page, string searchKeyword) { var dbPageResult = repo.GetSupplierByServiceTagsId(serviceTagsId, (page == 0 ? Constants.app_firstPage : page), Constants.app_totalRecords, searchKeyword); var PreferredSupplierList = await companySupplierRepo.GetPreferredSupplierByCompanyId(companyId); if (dbPageResult == null) { return(new VmCompanyPage()); } var resultObj = new VmCompanyPage(); resultObj.RequestId = DateTime.Now.ToString("yyyyMMddHHmmss"); resultObj.RequestDate = DateTime.Now; resultObj.Result = new PageResult <VmCompanyItem>(); var companyList = new List <VmCompanyItem>(); Copy <PageResult <Com.BudgetMetal.DBEntities.Company>, PageResult <VmCompanyItem> >(dbPageResult, resultObj.Result, new string[] { "Records" }); foreach (var dbItem in dbPageResult.Records) { var resultItem = new VmCompanyItem(); Copy <Com.BudgetMetal.DBEntities.Company, VmCompanyItem>(dbItem, resultItem); if (PreferredSupplierList.Contains(resultItem.Id)) { resultItem.OrderToShow = 1; } companyList.Add(resultItem); } resultObj.Result.Records = companyList.OrderByDescending(e => e.OrderToShow).ToList(); return(resultObj); }
public async Task <VmUserItem> GetFormObject() { VmUserItem result = new VmUserItem(); var dbCList = await cRepo.GetAll(); //filter with companyId var dbCCList = await CTrepo.GetAll(); var dbRoleList = await roleRepo.GetAll(); if (dbCList == null && dbCCList == null && dbRoleList == null) { return(result); } if (dbCList != null) { result.CompanyList = new List <VmCompanyItem>(); foreach (var dbcat in dbCList) { VmCompanyItem _company = new VmCompanyItem() { Id = dbcat.Id, Name = dbcat.Name }; result.CompanyList.Add(_company); } } if (dbCCList != null) { result.CodeTableList = new List <VmCodeTableItem>(); foreach (var dbcat in dbCCList) { VmCodeTableItem _codeTable = new VmCodeTableItem() { Id = dbcat.Id, Name = dbcat.Name }; result.CodeTableList.Add(_codeTable); } } if (dbRoleList != null) { result.RoleList = new List <VmRoleItem>(); foreach (var item in dbRoleList) { VmRoleItem _roleItem = new VmRoleItem() { Id = item.Id, Name = item.Name }; result.RoleList.Add(_roleItem); } } return(result); }
public async Task <VmCompanyItem> GetCompanyProfileById(int Id) { var dbPageResult = await repo.Get(Id); if (dbPageResult == null) { return(new VmCompanyItem()); } var resultObj = new VmCompanyItem(); Copy <Com.BudgetMetal.DBEntities.Company, VmCompanyItem>(dbPageResult, resultObj); resultObj.IsVerified = (dbPageResult.IsVerified == null) ? false : (bool)dbPageResult.IsVerified; var dbUserList = await repoUser.GetUserByCompanyNotFilterWithConfirm(Id); if (dbUserList == null) { return(resultObj); } resultObj.UserList = new List <VmUserItem>(); foreach (var dbUser in dbUserList) { List <VmRoleItem> rListItem = new List <VmRoleItem>(); if (dbUser.UserRoles != null) { foreach (var dbRoleItem in dbUser.UserRoles) { var dbRole = roleRepository.Get(dbRoleItem.Role_Id); if (dbRole != null) { VmRoleItem rItem = new VmRoleItem(); rItem.Id = dbRole.Result.Id; rItem.Name = dbRole.Result.Name; rItem.Code = dbRole.Result.Code; rListItem.Add(rItem); } } } VmUserItem user = new VmUserItem() { Id = dbUser.Id, UserName = dbUser.UserName, EmailAddress = dbUser.EmailAddress, JobTitle = dbUser.JobTitle, UserType = dbUser.UserType, IsConfirmed = dbUser.IsConfirmed, IsActive = dbUser.IsActive, RoleList = rListItem }; resultObj.UserList.Add(user); } var dbRepoList = await ratingRepo.GetRagintByCompany(Id); if (dbRepoList == null) { return(resultObj); } resultObj.RatingList = new List <VmRatingItem>(); foreach (var dbRating in dbRepoList) { VmRatingItem rating = new VmRatingItem() { SpeedOfQuotation = dbRating.SpeedOfQuotation, SpeedofDelivery = dbRating.SpeedofDelivery, ServiceQuality = dbRating.ServiceQuality, Price = dbRating.Price, SpeedofProcessing = dbRating.SpeedofProcessing, Payment = dbRating.Payment, Title = dbRating.Title, Description = dbRating.Description, Ratingcol = dbRating.Ratingcol, UserName = dbRating.User.ContactName }; //var rating = new VmRatingItem(); //Copy<Com.BudgetMetal.DBEntities.Rating, VmRatingItem>(dbRating, rating); resultObj.RatingList.Add(rating); } return(resultObj); }
public async Task <VmUserItem> GetUserById(int Id) { var dbPageResult = await repo.GetUserById(Id); if (dbPageResult == null) { return(new VmUserItem()); } var result = new VmUserItem(); Copy <Com.BudgetMetal.DBEntities.User, VmUserItem>(dbPageResult, result); var dbCList = await cRepo.GetAll(); //filter with companyId var dbCCList = await CTrepo.GetAll(); var dbRoleList = await roleRepo.GetAll(); if (dbCList == null && dbCCList == null && dbRoleList == null) { return(result); } if (dbCList != null) { result.CompanyList = new List <VmCompanyItem>(); foreach (var dbcat in dbCList) { VmCompanyItem _company = new VmCompanyItem() { Id = dbcat.Id, Name = dbcat.Name }; result.CompanyList.Add(_company); } } if (dbCCList != null) { result.CodeTableList = new List <VmCodeTableItem>(); foreach (var dbcat in dbCCList) { VmCodeTableItem _codeTable = new VmCodeTableItem() { Id = dbcat.Id, Name = dbcat.Name }; result.CodeTableList.Add(_codeTable); } } if (dbRoleList != null) { result.RoleList = new List <VmRoleItem>(); foreach (var item in dbRoleList) { VmRoleItem _roleItem = new VmRoleItem() { Id = item.Id, Name = item.Name }; result.RoleList.Add(_roleItem); } } if (dbPageResult.UserRoles != null) { if (dbPageResult.UserRoles.Count > 0) { result.SelectedRoleId = new List <int>(); foreach (var item in dbPageResult.UserRoles) { int roleId = item.Role_Id; result.SelectedRoleId.Add(roleId); } } else { //Add zero result.SelectedRoleId = new List <int>(); result.SelectedRoleId.Add(0); } } return(result); }