public ActionResult UpdatePackage(int packageid, company company)
        {
            try
            {
                packageUtil = new PackageUtil();
                package_subscription objsubscription = new package_subscription();
                var data = db.packages.AsEnumerable().Where(x => x.package_id == packageid).First();
                objsubscription.subscription_start_date = DateTime.Now;
                objsubscription.subscription_end_date   = DateTime.Now.AddDays(Convert.ToDouble(data.duration_days.duration_days_value));
                objsubscription.subscription_price      = data.setup_cost;
                objsubscription.subscription_discount   = 0;
                objsubscription.subscription_tax        = 0;
                objsubscription.user_id           = SessionUtil.GetUserID();
                objsubscription.per_user_price    = data.per_user_price;
                objsubscription.package_id        = data.package_id;
                objsubscription.duration_days_id  = data.duration_days_id;
                objsubscription.payment_status_id = 1;
                objsubscription.company_id        = company.company_id;
                result = packageUtil.Post_Package_Subscription(objsubscription);
                switch (result.MessageType)
                {
                case MessageType.Success:
                    return(RedirectToAction("EditCompany", "CompanySetting", new { id = company.company_id, Result = result.Message, MessageType = result.MessageType }));

                default:
                    return(RedirectToAction("Index", "CompanySetting", new { Result = result.Message, MessageType = result.MessageType }));
                }
            }
            catch
            {
                return(View());
            }
            return(View());
            //return RedirectToAction("Index", "Company", new { Result = result.Message, MessageType = result.MessageType });
        }
Beispiel #2
0
 public ActionResult CreateEditUser(user user, HttpPostedFileBase user_photo, FormCollection frmAdminUser)
 {
     try
     {
         user.role_id = String.IsNullOrEmpty(frmAdminUser["role_id"]) ? 0 : Convert.ToInt32(frmAdminUser["role_id"]);
         var     userdata           = db.users.Find(user.user_id);
         company CompanyInformation = db.companies.Find(user.company_id);
         if (user_photo != null)
         {
             string AWSProfileName    = STUtil.GetWebConfigValue("AWSProfileName");
             string GenFileName       = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + CompanyInformation.company_id.ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_");
             String companyFolderName = CompanyInformation.company_folder_name.ToString().Replace("/", "");
             //// AWSUtil.UploadFile(user_photo.InputStream, AWSProfileName, companyFolderName, GenFileName);
             user.user_photo = GenFileName;
         }
         else
         {
             user.user_photo = userdata != null ? userdata.user_photo : "NA.jpg";
         }
         user.parent_user_id = SessionUtil.GetUserID();
         result = userUtil.PostUserEdit(user);
     }
     catch (Exception ex)
     {
         result.Message     = ex.Message;
         result.MessageType = MessageType.Error;
     }
     return(RedirectToAction("Index", "User", new { id = String.Format("{0},{1}", user.role_id, user.role_bit), Result = result.Message, MessageType = result.MessageType }));
 }
 public ActionResult CreateEditUser(user user, HttpPostedFileBase user_photo, FormCollection frmAdminUser)
 {
     try
     {
         var     userdata           = db.users.Find(user.user_id);
         company CompanyInformation = db.companies.Find(user.company_id);
         if (user_photo != null)
         {
             string AWSProfileName    = STUtil.GetWebConfigValue("AWSProfileName");
             string GenFileName       = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + CompanyInformation.company_id.ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_");
             String companyFolderName = CompanyInformation.company_folder_name.ToString().Replace("/", "");
             /// AWSUtil.UploadFile(user_photo.InputStream, AWSProfileName, companyFolderName, GenFileName);
             user.user_photo = GenFileName;
         }
         else if (userdata != null)
         {
             user.user_photo = userdata.user_photo;
         }
         user.parent_user_id = SessionUtil.GetUserID();
         result = companyUtil.PostUserEdit(user);
     }
     catch (Exception ex)
     {
         result.Message     = ex.Message;
         result.MessageType = MessageType.Error;
     }
     return(RedirectToAction("EditCompany", "CompanySetting", new { id = user.company_id, Result = result.Message, MessageType = result.MessageType }));
 }
Beispiel #4
0
 public Result PostUserEdit(user user)
 {
     try
     {
         if (user.user_id > 0)
         {
             string password   = db.USP_GetUserPassword(user.user_id, user.company_id).ToList().FirstOrDefault().password;
             var    isUserEdit = db.USP_CreateUser(user.user_id, user.user_name, user.login_id, user.email_id, user.mobile, password,
                                                   user.gender, user.user_photo, user.parent_user_id, user.role_bit, user.company_id, user.created_by, user.role_id, null, user.create_work_order_access_id, user.view_work_order_access_id, user.is_change_requester, user.is_service_provider, user.is_active);
             result.Message = string.Format(BaseConst.MSG_SUCCESS_UPDATE, "User");
         }
         else
         {
             var pass       = STUtil.GetRandomPasswordNumber(6);
             int created_by = SessionUtil.GetUserID();
             var isUserEdit = db.USP_CreateUser(user.user_id, user.user_name, user.login_id, user.email_id, user.mobile, pass,
                                                user.gender, user.user_photo, user.parent_user_id, user.role_bit, user.company_id, created_by, user.role_id, null, user.create_work_order_access_id, user.view_work_order_access_id, user.is_change_requester, user.is_service_provider, true);
             result.Message = string.Format(BaseConst.MSG_SUCCESS_CREATE, "User");
         }
     }
     catch (Exception ex)
     {
         result.MessageType = MessageType.Error;
         result.Message     = ex.Message;
     }
     return(result);
 }
        // GET: MyProfile
        public ActionResult MyProfile()
        {
            ViewBag.Title = "My Profile";
            int  userid = SessionUtil.GetUserID();
            user user   = db.users.Find(userid);

            return(View(user));
        }
        public Result PostCompanyCreateEdit(COMPANY company, string userName, string loginID, string emailID, string mobile, string gender, string password, HttpPostedFileBase company_logo)
        {
            try
            {
                int userID = SessionUtil.GetUserID();
                if (company.CompanyId > 0)
                {
                    var tempCompanyId = SessionUtil.GetCompanyID();

                    COMPANY data = new COMPANY();
                    data                = db.COMPANies.Find(company.CompanyId);
                    data.CompanyName    = company.CompanyName;
                    data.ContactNumber  = company.ContactNumber;
                    data.CityId         = company.CityId;
                    data.GSTN           = company.GSTN;
                    data.CTSNumber      = company.CTSNumber;
                    data.CompanyAddress = company.CompanyAddress;
                    data.ContactPerson  = company.ContactPerson;
                    data.EmailId        = company.EmailId;
                    data.PAN            = company.PAN;
                    data.LogoImage      = company_logo != null ? company.LogoImage : data.LogoImage;
                    data.IsActive       = company.IsActive;

                    int sessionComId = (Int32)SessionUtil.GetCompanyID();

                    db.Entry(data).State = System.Data.Entity.EntityState.Modified;

                    BaseUtil.SetSessionValue(UserInfo.CompanyID.ToString(), company.CompanyId.ToString());

                    db.SaveChanges();

                    BaseUtil.SetSessionValue(UserInfo.CompanyID.ToString(), sessionComId.ToString());
                    result.Message = string.Format(BaseConst.MSG_SUCCESS_UPDATE, "Company");
                    result.Id      = company.CompanyId;
                }
                else
                {
                    db.COMPANies.Add(company);
                    db.SaveChanges();
                    result.Message     = string.Format(BaseConst.MSG_SUCCESS_CREATE, "Company");
                    result.MessageType = MessageType.Success;
                    result.Id          = company.CompanyId;
                }
            }
            catch (Exception ex)
            {
                result.MessageType = MessageType.Error;
                result.Message     = ex.Message;
            }
            return(result);
        }
Beispiel #7
0
        public ActionResult AddCompany(COMPANY company, FormCollection frmUser, HttpPostedFileBase company_logo)
        {
            try
            {
                string userName = frmUser["user_name"];
                string loginID  = frmUser["login_id"];
                string emailID  = frmUser["email_id"];
                string mobile   = frmUser["mobile"];
                string password = frmUser["password"];
                string gender   = frmUser["gender"];
                if (company_logo != null)
                {
                    #region Attache Documents
                    string        fileName    = string.Empty;
                    List <String> arrfileName = new List <String>();
                    int           loop        = 0;
                    // Verify that the user selected a file
                    if (company_logo != null && company_logo.ContentLength > 0)
                    {
                        // extract only the fielname
                        fileName = Guid.NewGuid() + "_" + SessionUtil.GetUserID() + "_" + Path.GetFileName(company_logo.FileName);
                        fileName = System.DateTime.Now.Millisecond.ToString() + Path.GetFileName(company_logo.FileName);
                        var path = Path.Combine(Server.MapPath("~/Files/"), fileName);
                        company_logo.SaveAs(path);
                        arrfileName.Add(fileName);
                    }
                    else
                    {
                        arrfileName.Add("NA.JPG");
                    }
                    loop++;

                    company.LogoImage = arrfileName[0].ToString();
                    #endregion
                    string GenFileName = BaseUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + SessionUtil.GetRoleBit().ToString() + "_" + Path.GetFileName(company_logo.FileName).Replace(" ", "_");

                    ///  CompanyInformation.company_logo = GenFileName;
                }
                BaseUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1");
                Session["a"] = 1;
                result       = companyUtil.PostCompanyCreateEdit(company, userName, loginID, emailID, mobile, gender, password, company_logo);
                BaseUtil.SetSessionValue(UserInfo.IsCompanySetup.ToString(), "1");
                return(RedirectToAction("CompanyTabs", new { id = result.Id, Result = result.Message, MessageType = result.MessageType }));
            }
            catch (Exception ex)
            {
                BaseUtil.SetSessionValue(UserInfo.IsCompanyAddUpdate.ToString(), "1");
                result.Message = ex.Message;
            }
            return(View());
        }
Beispiel #8
0
        public ActionResult UpdatePackage(int packageid, int company_id, int allow_users)
        {
            try
            {
                var     date        = DateTime.Now;
                decimal Total_Price = 0;

                var packagedatacount = db.package_subscription.AsEnumerable().Where(x => x.is_active && x.package_id == packageid && x.subscription_end_date >= date && x.company_id == CompanyId).FirstOrDefault();
                packageUtil = new PackageUtil();
                package_subscription objsubscription = new package_subscription();

                var data = db.packages.AsEnumerable().Where(x => x.package_id == packageid).First();
                objsubscription.subscription_start_date = DateTime.Now;
                objsubscription.subscription_end_date   = DateTime.Now.AddDays(Convert.ToDouble(data.duration_days.duration_days_value));
                objsubscription.allow_users             = allow_users;
                Total_Price = data.setup_cost + (data.per_user_price * allow_users);
                objsubscription.subscription_price          = Total_Price;//////////data.setup_cost; ///////////// Changed By Pravin
                objsubscription.subscription_discount       = 0;
                objsubscription.subscription_tax_display    = data.tax_display;
                objsubscription.subscription_tax_percentage = data.tax_percentage;
                objsubscription.subscription_tax            = Total_Price * ((data.tax_percentage) / 100); ///////0;
                objsubscription.user_id           = SessionUtil.GetUserID();
                objsubscription.setup_cost        = data.setup_cost;
                objsubscription.per_user_price    = data.per_user_price;
                objsubscription.package_id        = data.package_id;
                objsubscription.duration_days_id  = data.duration_days_id;
                objsubscription.payment_status_id = 1;
                objsubscription.company_id        = company_id;
                if (packagedatacount != null)
                {
                    objsubscription.package_subscription_id = packagedatacount.package_subscription_id;
                    objsubscription.payment_status_id       = packagedatacount.payment_status_id;
                }
                result = packageUtil.Post_Package_Subscription(objsubscription);
                switch (result.MessageType)
                {
                case MessageType.Success:
                    return(RedirectToAction("EditCompany", "Company", new { id = company_id, Result = result.Message, MessageType = result.MessageType }));

                default:
                    return(RedirectToAction("Index", "Company", new { Result = result.Message, MessageType = result.MessageType }));
                }
            }
            catch
            {
                return(View());
            }
            return(View());
            //return RedirectToAction("Index", "Company", new { Result = result.Message, MessageType = result.MessageType });
        }
        public ActionResult CreateEditClient(user user, HttpPostedFileBase user_photo, FormCollection frmAdminUser)
        {
            var isRole = frmAdminUser["IsJob"];
            var JobId  = frmAdminUser["hdnJobId"] == ""?0:Convert.ToInt32(frmAdminUser["hdnJobId"]);

            try
            {
                user.role_bit = (Int32)Role.Client;
                user.role_id  = db.roles.AsEnumerable().Where(x => x.role_bit == (Int32)Role.Client && x.company_id == (Int32)SessionUtil.GetCompanyID()).FirstOrDefault().role_id;
                var role = db.roles.AsEnumerable().Where(x => x.company_id == user.company_id && x.role_bit == (Int32)Role.Client && x.is_active).ToList();
                user.role_id = role.Count > 0 ? role.Select(x => x.role_id).FirstOrDefault() : 0;
                var     userdata           = db.users.Find(user.user_id);
                company CompanyInformation = db.companies.Find(user.company_id);
                if (user_photo != null)
                {
                    string AWSProfileName    = STUtil.GetWebConfigValue("AWSProfileName");
                    string GenFileName       = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + CompanyInformation.company_id.ToString() + "_" + Path.GetFileName(user_photo.FileName).Replace(" ", "_");
                    String companyFolderName = CompanyInformation.company_folder_name.ToString().Replace("/", "");
                    //// AWSUtil.UploadFile(user_photo.InputStream, AWSProfileName, companyFolderName, GenFileName);
                    user.user_photo = GenFileName;
                    UploadFile(SessionUtil.GetCompanyFolderName().ToString(), user_photo);
                }
                else
                {
                    user.user_photo = userdata != null ? userdata.user_photo : "NA.jpg";
                }
                user.parent_user_id = SessionUtil.GetUserID();
                result = userUtil.PostUserEdit(user);
            }
            catch (Exception ex)
            {
                result.Message     = ex.Message;
                result.MessageType = MessageType.Error;
            }
            if (string.IsNullOrEmpty(isRole))
            {
                return(RedirectToAction("Index", "Client", new { Result = result.Message, MessageType = result.MessageType }));
            }
            else
            {
                return(RedirectToAction("CreateEditJob", "Job", new { id = JobId, Result = result.Message, MessageType = result.MessageType }));
            }
        }
Beispiel #10
0
 public Result PostUserEdit(user user)
 {
     try
     {
         if (user.user_id > 0)
         {
             string password   = db.USP_GetUserPassword(user.user_id, user.company_id).ToList().FirstOrDefault().password;
             var    isUserEdit = db.USP_CreateUser(user.user_id, user.user_name, user.login_id, user.email_id, user.mobile, password,
                                                   user.gender, user.user_photo, user.parent_user_id, user.role_bit, user.company_id, user.created_by, user.role_id, user.payment_term_id, user.create_work_order_access_id, user.view_work_order_access_id, user.is_change_requester, user.is_service_provider, user.is_active).ToList();
             result.MessageType = isUserEdit.FirstOrDefault().UserID > 0 ? MessageType.Success : MessageType.Error;
             result.Message     = isUserEdit.FirstOrDefault().MSG;
             result.Id          = isUserEdit.FirstOrDefault().UserID > 0 ? isUserEdit.FirstOrDefault().UserID : 0;
         }
         else
         {
             var pass       = STUtil.GetRandomPasswordNumber(6);
             int created_by = SessionUtil.GetUserID();
             var isUserEdit = db.USP_CreateUser(user.user_id, user.user_name, user.login_id, user.email_id, user.mobile, pass,
                                                user.gender, user.user_photo, user.parent_user_id, user.role_bit, user.company_id, created_by, user.role_id, user.payment_term_id, user.create_work_order_access_id, user.view_work_order_access_id, user.is_change_requester, user.is_service_provider, true).ToList();
             result.Message     = string.Format(BaseConst.MSG_SUCCESS_CREATE, "User");
             result.MessageType = isUserEdit.FirstOrDefault().MSG == "Success" ? MessageType.Success : MessageType.Error;
             result.Message     = isUserEdit.FirstOrDefault().MSG;
             result.Id          = isUserEdit.FirstOrDefault().UserID > 0 ? isUserEdit.FirstOrDefault().UserID : 0;
         }
         if ((Int32)result.Id > 0)
         {
             var UserData = db.users.Find(result.Id);
             UserData.gstin_numer      = user.gstin_numer;
             UserData.billing_address  = user.billing_address;
             UserData.shipping_address = user.shipping_address;
             UserData.payment_terms    = user.payment_terms;
             db.Entry(UserData).State  = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         result.MessageType = MessageType.Error;
         result.Message     = ex.Message;
     }
     return(result);
 }
Beispiel #11
0
        public ActionResult UserCreateEdit(USER user, FormCollection frm, HttpPostedFileBase UserPhoto)
        {
            if (UserPhoto != null)
            {
                #region Attache Documents
                string        fileName    = string.Empty;
                List <String> arrfileName = new List <String>();
                int           loop        = 0;
                // Verify that the user selected a file
                if (UserPhoto != null && UserPhoto.ContentLength > 0)
                {
                    // extract only the fielname
                    fileName = Guid.NewGuid() + "_" + SessionUtil.GetUserID() + "_" + Path.GetFileName(UserPhoto.FileName);
                    fileName = System.DateTime.Now.Millisecond.ToString() + Path.GetFileName(UserPhoto.FileName);
                    var path = Path.Combine(Server.MapPath("~/Files/UsersPhoto/"), fileName);
                    UserPhoto.SaveAs(path);
                    arrfileName.Add(fileName);
                }
                else
                {
                    arrfileName.Add("NA.JPG");
                }
                loop++;

                user.UserPhoto = arrfileName[0].ToString();
                #endregion
            }
            string pass = frm["pass"] != null ? frm["pass"] : "";
            result = companyUtil.PostUserEdit(user, pass);
            switch (result.MessageType)
            {
            case MessageType.Success:
                return(RedirectToAction("CompanyTabs", "Company", new { id = user.CompanyId, Result = result.Message, MessageType = result.MessageType }));

            default:
                return(RedirectToAction("CompanyTabs", "Company", new { id = user.CompanyId, Result = result.Message, MessageType = result.MessageType }));
            }
        }
        public ActionResult ChangePassword(FormCollection frm)
        {
            try
            {
                int    User_id          = SessionUtil.GetUserID();
                string Old_password     = frm["oldPassword"];
                string New_password     = frm["newpassword"];
                string conform_password = frm["conformpassword"];
                result = userUtil.PostChangePassword(User_id, Old_password, New_password, conform_password);

                switch (result.MessageType)
                {
                case MessageType.Success:
                    return(RedirectToAction("ChangePassword", "MyProfile", new { Result = result.Message, MessageType = result.MessageType }));

                default:
                    return(RedirectToAction("ChangePassword", "MyProfile", new { Result = result.Message, MessageType = result.MessageType }));
                }
            }
            catch (Exception ex)
            {
            }
            return(View());
        }
Beispiel #13
0
        //public ActionResult IsScoreColumnExist(string id)
        //{
        //    //id="country_name,country_id"
        //    string[] info = id.Split(',');
        //    string scorecolumnname = id;
        //    int scorecolumnid = 0;
        //    if (info.Length == 2)
        //    {

        //        scorecolumnname = info[0];
        //        scorecolumnid = info[1] != "" ? Convert.ToInt32(info[1]) : scorecolumnid;
        //    }
        //    return Json(scoreColumnUtil.GetScoreColumnByScoreId(scorecolumnname, scorecolumnid) == null ? false : true);
        //}
        #endregion


        public ActionResult ChangeTheme(string id)
        {
            Result result       = new Result();
            var    colorCss     = "";
            int    themeColorId = Convert.ToInt32(id);

            switch ((ThemeColor)(themeColorId))
            {
            case ThemeColor.default_them:
                colorCss = "default.css";
                break;

            case ThemeColor.green:
                colorCss = "green.css";
                break;

            case ThemeColor.red:
                colorCss = "red.css";
                break;

            case ThemeColor.blue:
                colorCss = "blue.css";
                break;

            case ThemeColor.purple:
                colorCss = "purple.css";
                break;

            case ThemeColor.megna:
                colorCss = "megna.css";
                break;

            case ThemeColor.default_dark:
                colorCss = "default-dark.css";
                break;

            case ThemeColor.green_dark:
                colorCss = "green-dark.css";
                break;

            case ThemeColor.blue_dark:
                colorCss = "blue-dark.css";
                break;

            case ThemeColor.purple_dark:
                colorCss = "purple-dark.css";
                break;

            case ThemeColor.megna_dark:
                colorCss = "megna-dark.css";
                break;

            default:
                break;
            }
            STUtil.SetSessionValue(UserInfo.theme_color.ToString(), Convert.ToString(colorCss));
            user u = db.users.Find((Int32)SessionUtil.GetUserID());

            u.theme_color_id  = themeColorId;///colorCss.ToString();
            db.Entry(u).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            result.MessageType = MessageType.Success;
            result.Message     = "Theme Apply Successfully";
            return(RedirectToAction("Index", "DashBoard", new { Result = result.Message, MessageType = result.MessageType }));
        }
Beispiel #14
0
 public Result PostCreateEdit(user user, FormCollection frm)
 {
     try
     {
         string password = frm["userpassword"];
         db = new BaseEntities();
         if (user.user_id > 0)
         {
             var msg = db.USP_CreateUser(user.user_id, user.user_name, user.login_id, user.email_id, user.mobile, password, user.gender, user.user_photo, user.parent_user_id, user.role_bit, SessionUtil.GetCompanyID(), SessionUtil.GetUserID(), user.role_id, null, user.create_work_order_access_id, user.view_work_order_access_id, user.is_change_requester, user.is_service_provider, user.is_active).FirstOrDefault().MSG;
             result.Message = msg == "Success" ? string.Format(BaseConst.MSG_SUCCESS_CREATE, "User") : msg;
         }
         else
         {
             user.is_active = true;
             var msg = db.USP_CreateUser(user.user_id, user.user_name, user.login_id, user.email_id, user.mobile, password, user.gender, user.user_photo, user.parent_user_id, user.role_bit, SessionUtil.GetCompanyID(), SessionUtil.GetUserID(), user.role_id, null, user.create_work_order_access_id, user.view_work_order_access_id, user.is_change_requester, user.is_service_provider, user.is_active).FirstOrDefault().MSG;
             result.Message = msg == "Success" ? string.Format(BaseConst.MSG_SUCCESS_UPDATE, "User") : msg;
         }
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         result.MessageType = MessageType.Error;
         result.Message     = ex.Message;
     }
     return(result);
 }
Beispiel #15
0
        public ActionResult EmailSettingsList(int id)
        {
            var list = db.email_setting.AsEnumerable().ToList();
            //list = list.Where(x => x.email_setting_type.is_public).ToList();
            var data = (from li in list
                        where li.company_id == SessionUtil.GetCompanyID() && li.user_id == SessionUtil.GetUserID()
                        select new
            {
                email_setting_id = li.email_setting_id,
                from_email_id = li.from_email_id,
                from_email_name = li.from_email_name,
                email_user_name = li.email_user_name,
                email_setting_type_name = li.email_setting_type.email_setting_type_name,
                is_public = li.email_setting_type.is_public,
                is_active = li.is_active,
                company_id = li.company_id,
                created_date = li.created_date,
                created_by = li.created_by,
                updated_date = li.updated_date,
                updated_by = li.updated_by,
            }).ToList();

            return(Json(data));
        }
Beispiel #16
0
        public Result PostCompanyCreateEdit(company company, HttpPostedFileBase company_logo, string userName, string loginID, string emailID, string mobile, string gender, string password)
        {
            try
            {
                string  AWSProfileName = STUtil.GetWebConfigValue("AWSProfileName");
                int     userID         = SessionUtil.GetUserID();
                company companyEdit    = new company();
                if (company_logo != null)
                {
                    string GenFileName = STUtil.GetTodayDate().ToString("yyyyMMdd") + "_" + company.company_id.ToString() + "_" + Path.GetFileName(company_logo.FileName).Replace(" ", "_");
                    company.company_logo = GenFileName;
                }
                if (company.company_id > 0)
                {
                    companyEdit          = db.companies.Find(company.company_id);
                    company.company_logo = (company.company_logo != "" && company.company_logo != null) ? company.company_logo : (companyEdit.company_logo);
                    var isUpadte = db.USP_UpdateCompany(company.company_id, userID, company.business_name, company.time_zone, company.country_code,
                                                        company.phone, company.state_id, company.city, company.address, company.zip, companyEdit.admin_user_name, company.is_active,
                                                        System.DateTime.Now, company.licence_no, company.company_logo);
                    db.SaveChanges();

                    #region FileUpload
                    if (company_logo != null)
                    {
                        String companyFolderName = companyEdit.company_folder_name.Replace("/", "");
                        //// AWSUtil.UploadFile(company_logo.InputStream, AWSProfileName, companyFolderName, company.company_logo);
                    }
                    #endregion

                    result.Message = string.Format(BaseConst.MSG_SUCCESS_UPDATE, "Company");
                    result.Id      = company.company_id;
                }
                else
                {
                    var companyInfo = db.USP_Create_Company_user_SA(company.time_zone, company.business_name, company.country_code, company.phone,
                                                                    company.address, company.city, company.zip, company.state_id, userName, loginID,
                                                                    mobile, emailID, password, gender, company.licence_no, company.company_logo);
                    db.SaveChanges();
                    result.Message     = string.Format(BaseConst.MSG_SUCCESS_CREATE, "Company");
                    result.MessageType = MessageType.Success;
                    ///result.Id = companyInfo.FirstOrDefault().company_id;
                    #region FolderCreation
                    //string company_folder_name = companyInfo.FirstOrDefault().company_folder_name;
                    //string company_folder_name = "COMPANY_73_20180719/";
                    //////AWSUtil.FolderCreation(AWSProfileName, company_folder_name);
                    #endregion

                    #region FileUpload
                    if (company_logo != null)
                    {
                        // String companyFolderName = company_folder_name.Replace("/", "");
                        //    AWSUtil.UploadFile(company_logo.InputStream, AWSProfileName,  companyFolderName, company.company_logo);
                    }
                    #endregion


                    //#region SendMail
                    //string EMAIL_TEMPALTE_FOLDER = STUtil.GetWebConfigValue("EMAIL_TEMPALTE_FOLDER");
                    //var emailTempRecord = db.email_template.AsEnumerable().Where(x => x.email_template_type_id == 5).OrderByDescending(x => x.email_template_id).FirstOrDefault();//5 - ACCOUNT_ACTIVATED
                    //if (emailTempRecord != null)
                    //{
                    //    ImagePath = STUtil.GetWebConfigValue("ImagePath");
                    //    EMAIL_TEMPALTE_FOLDER = STUtil.GetWebConfigValue("EMAIL_TEMPALTE_FOLDER");
                    //    string APPLICATION_URL = STUtil.GetWebConfigValue("APPLICATION_URL");
                    //    String templateName = ImagePath + EMAIL_TEMPALTE_FOLDER + "/" + emailTempRecord.email_template_file_name;
                    //    var filePath = (new WebClient()).DownloadString(templateName);
                    //    //filePath = filePath.Replace("{UserName}", companyInfo.user_name);
                    //    //filePath = filePath.Replace("{business_name}", companyInfo.business_name);
                    //    filePath = filePath.Replace("{LOGIN_ID}", loginID);
                    //    filePath = filePath.Replace("{PASSWORD}", password);
                    //    filePath = filePath.Replace("{EMAIL_ID}", emailID);
                    //    filePath = filePath.Replace("{APPLICATION_URL}", APPLICATION_URL);
                    //    STUtil.SendMail(emailID, "Welcome to SnagTick: " + loginID, filePath, null);
                    //}
                    //#endregion
                }
            }
            catch (Exception ex)
            {
                result.MessageType = MessageType.Error;
                result.Message     = ex.Message;
            }
            return(result);
        }