public bool AddCompanyViewLog(CompanyViewLog companyViewLog) { try { companyViewLog.State = ObjectState.Added; _crudOperation.AddOperation(companyViewLog); return true; } catch (Exception ex) { var errorMsg = ex.Message; return false; } }
public ActionResult Add(Company company) { try { string startTrial = Request.Form["startTrial"]; string buyNow = Request.Form["buyNow"]; company.Email = HttpContext.User.Identity.Name; var tt = uService.GetSingleUserByEmail(company.Email); company.Users = new User { Id = tt.Id, Email = tt.Email }; string msg=""; var chkTrading = iCompany.IsTradingNameUnique(company, out msg); if (!chkTrading) { TempData.Add("errMsg",msg); return RedirectToAction("Add"); } if (iCompany.AddCompany(company)) { // company view log var cViewlog = new CompanyViewLog(); cViewlog.CompanyId = company.Id; cViewlog.UserId = tt.Id; cViewlog.LoginTime = DateTime.Now; _companyViewLog.AddCompanyViewLog(cViewlog); // insert default data for company var rr = iCompany.InsertDefaultDataForCompany(company.Id); if (startTrial != null) { return RedirectToAction("Update", "Company", new { Area = "OrganizationManagement" }); } else { return RedirectToAction("payment", "Company", new { Area = "OrganizationManagement" }); } } else { return RedirectToAction("Add", "Company", new { Area = "OrganizationManagement" }); } } catch (Exception Ex) { return RedirectToAction("Add", "Company", new { Area = "OrganizationManagement" }); } }
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 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" }); } }