Esempio n. 1
0
 public ActionResult UserEdit(CompanyClass company, HttpPostedFileBase file)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Company obj = db.Company.Find(company.CompanyKey);
             if (file != null)
             {
                 byte[] data = null;
                 using (Stream inputStream = file.InputStream)
                 {
                     MemoryStream memoryStream = inputStream as MemoryStream;
                     if (memoryStream == null)
                     {
                         memoryStream = new MemoryStream();
                         inputStream.CopyTo(memoryStream);
                     }
                     data = memoryStream.ToArray();
                 }
                 obj.Logo     = data;
                 obj.LogoType = file.ContentType;
             }
             company               = val.ValidateCompanyClass(company);
             obj.CompanyID         = company.CompanyID;
             obj.CompanyName       = company.CompanyName;
             obj.ZIPKey            = company.ZIPKey;
             obj.StateCode         = company.StateCode;
             obj.CityKey           = company.CityKey;
             obj.CompanyAddress    = company.CompanyAddress;
             obj.CompanyPhone      = company.CompanyPhone;
             obj.CompanyMobile     = company.CompanyMobile;
             obj.CompanyEmail      = company.CompanyEmail;
             obj.CompanyWebsite    = company.CompanyWebsite;
             obj.CompanyFax        = company.CompanyFax;
             obj.ContactPersonName = company.ContactPersonName;
             obj.ContactPersonNo   = company.ContactPersonNo;
             obj.Title             = company.Title;
             obj.ContactEmail      = company.ContactEmail;
             db.SaveChanges();
             return(RedirectToAction("UserDetails"));
         }
         return(View(company));
     }
     catch (Exception e)
     {
         return(View("Error", new HandleErrorInfo(e, "Index", "UserHome")));
     }
 }