Exemplo n.º 1
0
 public bool CreateEmployee(Employee emp)
 {
     try
     {
         emp.State = ObjectState.Added;
         empRep.AddOperation(emp);
         return true;
     }
     catch (Exception ex)
     {
         var msg = ex.Message;
         return false;
     }
 }
Exemplo n.º 2
0
 public bool UpdateEmployee(Employee emp)
 {
     try
     {
         emp.State = ObjectState.Modified;
         empRep.UpdateOperation(emp);
         return true;
     }
     catch (Exception ex)
     {
         var msg = ex.Message;
         return false;
     }
 }
Exemplo n.º 3
0
        public ActionResult InvitationConfirm(int id, string token)
        {
            var Invitation = inService.GetSingleInvitation(id);
            if (Invitation != null)
            {
                if (Invitation.Token == token)
                {
                    if (Invitation.Status != StatusEnum.test2)
                    {

                        Invitation.Status = StatusEnum.test2;
                        inService.AcceptInvitation(Invitation);
                        ViewBag.Company = Invitation.CompanyId;
                        ViewBag.email = Invitation.Email;
                        var user = uService.GetSingleUserByEmail(Invitation.Email);
                        if (user == null)
                        {
                            return View("InvitationConfirm");
                        }
                        else
                        {
                            var emp = new Employee();
                            emp.UserId = user.Id;
                            emp.CompanyId = Invitation.CompanyId;
                            emp.DesignationId = Invitation.DesignationId;
                            if (eService.CreateEmployee(emp))
                            {
                                var userInRole = new UserInRole();
                                userInRole.EmployeeId = emp.Id;
                                userInRole.RoleId = Invitation.RoleId;
                                userInRole.IsActive = true;
                                URSer.AddUserInRole(userInRole);

                                Session.Add("msg", "You have to login first");
                                return Redirect(Url.Content("~/"));

                            }
                            else
                            {
                                return Content("Employee Profile couldn't be completed");
                            }
                        }

                    }
                    else
                    {
                        return Content("You are trying to use a token that is already used !");
                    }

                    // return RedirectToAction("Index");
                }
                else
                {
                    return Content("token mismatch");
                }
            }
            else
            {
                return Content("Invitation Not Found!");
            }
        }
Exemplo n.º 4
0
        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");
        }
Exemplo n.º 5
0
        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();
        }