示例#1
0
        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());
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
        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));
        }
示例#6
0
        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));
        }
示例#7
0
        public IActionResult Clear()
        {
            vmCompany companyCreate = new vmCompany();

            return(PartialView("_CreateView", companyCreate));
        }