public IActionResult MyCompany() { vmCompany myVM = new vmCompany(); myVM.Company = _context.Companies.Find(_CurrentUserCompanyID()); if (myVM.Company != null) { myVM.Token = _GetToken(); return(View(myVM)); } else { return(new NotFoundResult()); } }
private List <vmCompany> GetDeleteComapny(List <vmCompany> companyList, int?userID) { _ctxCmn = new ERP_Entities(); List <vmCompany> _DeleteList = new List <vmCompany>(); List <CmnUserWiseCompany> cmUserWiseComapnylist = _ctxCmn.CmnUserWiseCompanies.Where(x => x.UserID == userID && x.IsDeleted == false).ToList(); foreach (CmnUserWiseCompany aitem in cmUserWiseComapnylist) { vmCompany isExistCompany = companyList.Where(x => x.id == aitem.CompanyID).FirstOrDefault(); if (isExistCompany == null) { vmCompany _objvmCompany = new vmCompany(); _objvmCompany.id = aitem.CompanyID; _DeleteList.Add(_objvmCompany); } } return(_DeleteList); }
public IActionResult Details(int companyId) { var company = _db.Company.Get(companyId); vmCompany vmCompany = new vmCompany(); vmCompany.CompanyName = company.CompanyName; vmCompany.Phone = company.Phone; vmCompany.Email = company.Email; vmCompany.Address = company.Address; vmCompany.Web = company.Web; vmCompany.ContactPerson = company.ContactPerson; vmCompany.ContactPersonNumber = company.ContactPersonNumber; vmCompany.ContactPersonEmail = company.ContactPersonEmail; vmCompany.ContactPersonDesignation = company.ContactPersonDesignation; vmCompany.LogoUrl = company.Logo; vmCompany.IsActive = true; return(PartialView("_Details", vmCompany)); }
public IActionResult Create(vmCompany vmCompany) { if (ModelState.IsValid) { Company company = new Company() { CompanyName = vmCompany.CompanyName, Phone = vmCompany.Phone, Email = vmCompany.Email, Address = vmCompany.Address, Web = vmCompany.Web, ContactPerson = vmCompany.ContactPerson, ContactPersonNumber = vmCompany.ContactPersonNumber, ContactPersonEmail = vmCompany.ContactPersonEmail, ContactPersonDesignation = vmCompany.ContactPersonDesignation, CompanyType = vmCompany.CompanyType, BusinessType = vmCompany.BusinessType, IsActive = true, IsDeleted = false }; if (vmCompany.Logo != null) { var fileName = ContentDispositionHeaderValue.Parse(vmCompany.Logo.ContentDisposition).FileName.Trim('"').Replace(" ", string.Empty); List <string> fileSplitNames = fileName.Split(".").ToList(); fileName = fileSplitNames[0] + DateTime.Now.ToString("dddd_dd_MMMM_yyyy_HH_mm_ss") + "." + fileSplitNames[1]; var path = _imagePath.GetImagePath(fileName, "Uploads", "Company"); using (var stream = new FileStream(path, FileMode.Create)) { vmCompany.Logo.CopyTo(stream); } company.Logo = _imagePath.GetImagePathForDb(path); } _db.Company.Add(company); bool isSaved = _db.Save() > 0; ModelState.Clear(); vmCompany model = new vmCompany(); return(PartialView("_CreateView", model)); } return(PartialView("_CreateView", vmCompany)); }
public IActionResult EditView(int id) { var Company = _db.Company.Get(id); vmCompany vmCompanyEdit = new vmCompany(); vmCompanyEdit.Id = Company.Id; vmCompanyEdit.CompanyName = Company.CompanyName; vmCompanyEdit.Phone = Company.Phone; vmCompanyEdit.Email = Company.Email; vmCompanyEdit.Address = Company.Address; vmCompanyEdit.Web = Company.Web; vmCompanyEdit.Email = Company.Email; vmCompanyEdit.ContactPerson = Company.ContactPerson; vmCompanyEdit.ContactPersonNumber = Company.ContactPersonNumber; vmCompanyEdit.ContactPersonEmail = Company.ContactPersonEmail; vmCompanyEdit.ContactPersonDesignation = Company.ContactPersonDesignation; vmCompanyEdit.CompanyType = Company.CompanyType; vmCompanyEdit.BusinessType = Company.BusinessType; vmCompanyEdit.LogoUrl = Company.Logo; return(PartialView("_EditView", vmCompanyEdit)); }
public IActionResult Edit(vmCompany vmCompany) { if (ModelState.IsValid) { Company company = db.Company.GetFirstOrDefault(c => c.Id == vmCompany.Id); company.CompanyName = vmCompany.CompanyName; company.Phone = vmCompany.Phone; company.Email = vmCompany.Email; company.Address = vmCompany.Address; company.Web = vmCompany.Web; company.ContactPerson = vmCompany.ContactPerson; company.ContactPersonNumber = vmCompany.ContactPersonNumber; company.ContactPersonEmail = vmCompany.ContactPersonEmail; company.ContactPersonDesignation = vmCompany.ContactPersonDesignation; company.IsActive = true; if (vmCompany.Logo != null) { var companyUrl = _imagePath.GetSourceUrlToFilePath(company.Logo); _imagePath.RemoveFileOfPath(companyUrl); var fileName = ContentDispositionHeaderValue.Parse(vmCompany.Logo.ContentDisposition).FileName.Trim('"').Replace(" ", string.Empty); var path = _imagePath.GetImagePath(fileName, "Company", vmCompany.CompanyName); using (var stream = new FileStream(path, FileMode.Create)) { vmCompany.Logo.CopyTo(stream); } company.Logo = _imagePath.GetImagePathForDb(path); } _db.Company.Update(company); _db.Save(); bool isSaved = _db.Save() > 0; ModelState.Clear(); vmCompany model = new vmCompany(); return(PartialView("_CreateView", model)); } return(PartialView("_EditView", vmCompany)); }
public IActionResult Clear() { vmCompany companyCreate = new vmCompany(); return(PartialView("_CreateView", companyCreate)); }