public bool AddSettings(Settings setting) { try { setting.State = ObjectState.Added; setRep.AddOperation(setting); return true; } catch (Exception ex) { var rr = ex.Message; return false; } }
public bool UpdateSettings(Settings setting) { try { var dbObj = setRep.GetSingleObject(setting.Id); dbObj.lgcompany = setting.lgcompany; dbObj.lgdash = setting.lgdash; dbObj.lglast = setting.lglast; dbObj.CompanyId = setting.CompanyId; dbObj.State = ObjectState.Modified; setRep.UpdateOperation(dbObj); return true; }catch(Exception ex){ var rr = ex.Message; return false; } }
public ActionResult InvitationConfirm(int id, User user) { var tnc = Request.Params.Get("tnc"); if (tnc != null && tnc == "on") { Encryptor encrypt = new Encryptor(); user.Password = encrypt.GetMD5(user.Password); user.ConfirmPassword = encrypt.GetMD5(user.ConfirmPassword); if (uService.GetSingleUserByEmail(user.Email) == null) { if (uService.AddUser(user)) { var Invitation = inService.GetSingleInvitation(id); var emp = new Employee(); var setObj = setService.GetAllByUserId(user.Id); var logEntry = new CompanyViewLog(); logEntry.UserId = user.Id; logEntry.CompanyId = Invitation.CompanyId; ; logEntry.LoginTime = DateTime.Now; //logEntry.IpAddress = ""; _companyViewLog.AddCompanyViewLog(logEntry); emp.UserId = user.Id; emp.CompanyId = Invitation.CompanyId; emp.DesignationId = Invitation.DesignationId; if (eService.CreateEmployee(emp)) { var accountSetting = new Settings(); accountSetting.userId = user.Id; accountSetting.lgdash = false; accountSetting.lglast = false; accountSetting.lgcompany = true; accountSetting.CompanyId = Invitation.CompanyId; if (sService.AddSettings(accountSetting)) { var userInRole = new UserInRole(); userInRole.EmployeeId = emp.Id; userInRole.RoleId = Invitation.RoleId; userInRole.IsActive = true; if (URSer.AddUserInRole(userInRole)) { CustomPrincipal.Login(user.Email, user.Password, false); return RedirectToAction("Create", "EmployeeProfile", new { area = "OrganizationManagement" }); } } } else { return Content("Failed"); } } } else { ModelState.AddModelError("Msg", "Already Register"); //return Content("Already Register"); return View(); } } return Content("You Must Agree with our terms and Condition"); }
public ActionResult UpdateSettings(bool lgcompany, bool lgdash, bool lglast, int TimezoneId, int? ComanyId) { var email = HttpContext.User.Identity.Name; var users = uService.GetSingleUserByEmail(email); var setObj = setService.GetAllByUserId(users.Id); //var logEntry = new CompanyViewLog()AddCompanyViewLog; //logEntry.UserId = users.Id; //logEntry.CompanyId = ComanyId; //logEntry.LoginTime = DateTime.Now; ////logEntry.IpAddress = ""; //_companyViewLog.AddCompanyViewLog(logEntry); if (setObj != null) { setObj.userId = users.Id; setObj.lgcompany = lgcompany; setObj.lgdash = lgdash; setObj.lglast = lglast; setObj.TimezoneId = TimezoneId; setObj.CompanyId = ComanyId; setService.UpdateSettings(setObj); return Json(new { success = "True" }); } else { Settings newObj = new Settings(); newObj.userId = users.Id; newObj.lgcompany = lgcompany; newObj.lgdash = lgdash; newObj.lglast = lglast; newObj.TimezoneId = TimezoneId; newObj.CompanyId = ComanyId; setService.AddSettings(newObj); return Json(new { success = "True" }); } }
public ActionResult UpdateCompnay(int ComanyId) { var email = HttpContext.User.Identity.Name; var users = uService.GetSingleUserByEmail(email); var setObj = setService.GetAllByUserId(users.Id); var logEntry = new CompanyViewLog(); logEntry.UserId = users.Id; logEntry.CompanyId = ComanyId; logEntry.LoginTime = DateTime.Now; //logEntry.IpAddress = ""; _companyViewLog.AddCompanyViewLog(logEntry); try { if (setObj != null) { setObj.userId = users.Id; setObj.CompanyId = ComanyId; setService.UpdateSettings(setObj); return Json(new { success = "True" }); } else { Settings newObj = new Settings(); newObj.userId = users.Id; newObj.CompanyId = ComanyId; setService.AddSettings(newObj); return Json(new { success = "True" }); } } catch (Exception ex) { var msg = ex.Message; return Json(new { success = "False" }); } }
public JsonResult GetSettingsByUserId() { var setObj = new Settings(); try { var email = HttpContext.User.Identity.Name; var users = uService.GetSingleUserByEmail(email); setObj = setService.GetAllByUserId(users.Id); } catch (Exception ex) { var rr = ex.Message; } return Json(setObj, JsonRequestBehavior.AllowGet); }
public ActionResult Registration(Company company) { HttpPostedFileBase logo = Request.Files["logoImage"]; HttpPostedFileBase seal = Request.Files["sealImage"]; //HttpPostedFileBase doc = Request.Files["documentLocation[]"]; int companyTableId = iCompany.GetMaxId() + 1; string sealName = "Seal_" + company.TradingName.Replace(" ", "_") + "_" + companyTableId.ToString() + "_" + Path.GetRandomFileName() + ".png"; string sealLocation = Server.MapPath("~/Uploads/" + company.TradingName.Replace(" ", "_") + "/"); string logoName = "Logo_" + company.TradingName.Replace(" ", "_") + "_" + companyTableId.ToString() + "_" + Path.GetRandomFileName() + ".png"; string logoLocation = Server.MapPath("~/Uploads/" + company.TradingName.Replace(" ", "_") + "/"); string msg = "", logoUploadMsg = "", sealUploadMsg = "", designationInsertMsg = "", employeeAddMsg = "", documentAddMsg = "", settingMsg = ""; bool success = false, uploadSuccess = true; string documentName; string documentLocation; if (logo.ContentLength > 1) { if (fileUpload(logo, logoName, logoLocation)) { company.LogoLocation = "Uploads/" + company.TradingName.Replace(" ", "_") + "/" + logoName; } else { logoUploadMsg = "Problem in logo uploading...Please try Again later.."; uploadSuccess = false; } } if (seal.ContentLength > 1) { if (fileUpload(seal, sealName, sealLocation)) { company.SealLocation = "Uploads/" + company.TradingName.Replace(" ", "_") + "/" + sealName; } else { sealUploadMsg = "Problem in Seal uploading...Please try Again later.."; uploadSuccess = false; } } company.Email = HttpContext.User.Identity.Name; var tt = uService.GetSingleUserByEmail(company.Email); company.Users = new User { Id = tt.Id, Email = tt.Email }; try { if (iCompany.AddCompany(company)) { success = true; var ownerDesignation = iDesignation.GetSingleDesignationByDesignationName("Owner"); if (ownerDesignation == null) { Designation ds = new Designation(); ds.DesignationName = "Owner"; if (iDesignation.AddDesignation(ds)) ownerDesignation = ds; else { //designation add failed designationInsertMsg = "Internal Server Error regarding Designation...Please consult with Mhasb Team"; } } Employee ownerEmp = new Employee(); ownerEmp.UserId = tt.Id; ownerEmp.CompanyId = company.Id; ownerEmp.DesignationId = ownerDesignation.Id; ownerEmp.BranchId = company.Id; if (!iEmployee.CreateEmployee(ownerEmp)) { //Employee add failed designationInsertMsg = "Internal Server Error regarding Employee...Please consult with Mhasb Team"; } var accountSetting = sService.GetAllByUserId(tt.Id); if (accountSetting != null) { accountSetting.Companies = new Company { Id = company.Id }; accountSetting.lgcompany = true; if (!sService.UpdateSettings(accountSetting)) settingMsg = "Internal Server Error regarding Account Setting...Please consult with Mhasb Team "; } else { var AccSet = new Settings(); AccSet.userId = tt.Id; AccSet.lgdash = false; AccSet.lglast = false; AccSet.CompanyId = company.Id; AccSet.lgcompany = true; if (!sService.AddSettings(AccSet)) settingMsg = "Internal Server Error regarding Account Setting...Please consult with Mhasb Team"; } for (int i = 0; i < Request.Files.Count; i++) { if ("documentLocation[]" == Request.Files.GetKey(i) && Request.Files.GetKey(i).Length > 1) { documentName = "Document_" + company.TradingName.Replace(" ", "_") + "_" + companyTableId.ToString() + "_" + Path.GetRandomFileName() + Path.GetExtension(Request.Files[i].FileName); documentLocation = Server.MapPath("~/Uploads/" + company.TradingName.Replace(" ", "_") + "/"); if (fileUpload(Request.Files[i], documentName, documentLocation)) { CompanyDocument cd = new CompanyDocument(); cd.CompanyId = company.Id; cd.DocumentOriginalName = Request.Files[i].FileName; cd.DocumentLocation = "Uploads/" + company.TradingName.Replace(" ", "_") + "/" + documentName; if (!iCompanyDocument.AddCompanyDocument(cd)) { documentAddMsg = "One or more document didnot upload successfully"; uploadSuccess = false; } } } } msg = "Success"; } else msg = "Registration Failed"; } catch (Exception) { msg = "Exception Occured. Please Contact with Mhasb Team"; } TempData.Add("errMsg", msg + logoUploadMsg + sealUploadMsg + documentAddMsg + designationInsertMsg + employeeAddMsg + settingMsg); if (success && uploadSuccess) return RedirectToAction("MyMhasb", "Users", new { Area = "UserManagement" }); else if (!uploadSuccess) return RedirectToAction("update"); else return View(); }