Example #1
0
 public ActionResult AddCompanyManager(ServiceFirstCompanyManager _objCompanyManager, HttpPostedFileBase file)
 {
     if (file != null && file.ContentLength > 0)
     {
         try
         {
             string path = System.IO.Path.Combine(Server.MapPath("~/Images"),
                                                  System.IO.Path.GetFileName(file.FileName));
             file.SaveAs(path);
             _objCompanyManager.ServiceFirstCompanyManagerLogoFile = file.FileName;
         }
         catch (Exception ex)
         {
             ViewBag.Message = "ERROR:" + ex.Message.ToString();
         }
     }
     if (_objCompanyManager.ServiceFirstCompanyManagerID == 0)
     {
         if (ModelState.IsValid)
         {
             AdminUsers obj = new AdminUsers();
             if (obj.AddCompanyManager(_objCompanyManager))
             {
                 ViewBag.Message = "Created Successfully";
             }
             else
             {
                 ViewBag.Message = obj.Message;
             }
         }
         else
         {
             ViewBag.Message = "Not Created Successfully";
         }
     }
     else
     {
         try
         {
             if (ModelState.IsValid)
             {
                 AdminUsers obj = new AdminUsers();
                 if (obj.EditCompanyManager(_objCompanyManager))
                 {
                     ViewBag.Message = "Saved Successfully";
                 }
                 else
                 {
                     ViewBag.Message = obj.Message;
                 }
             }
             else
             {
                 ViewBag.Message = "Not Saved successfully";
             }
         }
         catch (Exception ex)
         {
             ViewBag.Message = "Error occured:" + ex.Message;
         }
     }
     return(RedirectToAction("AddCompanyManager", "Admin", new { message = ViewBag.Message, id = 0 }));
 }