예제 #1
0
        public IActionResult UpdateCompany(CompanyVM companyVM, int id)
        {
            User    currentAdmin = HttpContext.Session.Get <User>("currentUser");
            Company company      = companyBLL.Get(id).Data;

            try
            {
                if (ModelState.IsValid)
                {
                    company.CompanyName   = companyVM.CompanyName;
                    company.Overview      = companyVM.Overview;
                    company.Location      = companyVM.Location;
                    company.WebSite       = companyVM.WebSite;
                    company.SubCategoryID = companyVM.SubCatID;

                    if (company != null)
                    {
                        try
                        {
                            companyBLL.Update(company);
                            this._logger.LogInformation($"AdminID : {currentAdmin.ID} is updated  CompanyID : {company.ID}.");
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                        ViewBag.IsSuccess = true;
                    }
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                ViewBag.IsSuccess = false;
            }
            return(View("Index"));
        }