Exemplo n.º 1
0
        public HttpResponseMessage Post([FromBody] EmployeeDetailsModel model) // TODO first & last combine it
        {
            if (model.CompanyID == null && !model.IsNewRecord)
            {
                List <CompanyDetailModel> companyDetails = _companyDetailService.GetCompanyDetails().ToList();
                foreach (var company in companyDetails)
                {
                    if (company.CompanyName != null)

                    {
                        if (company.CompanyName.Trim().ToUpper() == model.CompanyName.Trim().ToUpper())
                        {
                            return(Request.CreateResponse(HttpStatusCode.BadRequest, new { Result = "company already exists!" }));
                        }
                    }
                }

                if (_employeeDetailsService.HasEmailIdExists(model.EmailID))
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, new { Result = "Email Id already exists!" }));
                }

                if (_employeeDetailsService.HasCompanyUrlxists(model.CompanyUrl))
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, new { Result = "Company URL already exists!" }));
                }

                model.CompanyID = SaveCompanyDetails(model.CompanyName);
            }
            //string passwordHashSalt = string.Empty;
            //passwordHashSalt = PasswordHash.CreateHash("");
            // string[] passwordValues = passwordHashSalt.Split(':');
            //model.PasswordSalt = Convert.ToString(passwordValues[1]).Trim();
            //model.PasswordHash = Convert.ToString(passwordValues[2]).Trim();
            model.PasswordSalt = model.Password;
            model.CreatedBy    = User.Identity.Name;
            model.CreatedDate  = DateTime.Now;
            if (model.CompanyID == null || model.CompanyID == 0)
            {
                model.CompanyID = CompanyId;
            }

            //List<tblEmployeeJobDetailsModel> list = new List<tblEmployeeJobDetailsModel>();
            //list.Add(model.objtblEmployeeJobDetails);
            //model.tblEmployeeJobDetails = list;
            model.Status = true;
            if (_employeeDetailsService.HasEmailIdExists(model.EmailID))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new { Result = "Email Id already exists!" }));
            }
            int result = _employeeDetailsService.SaveEmployee(model);

            // while registration company url is mandartory and send email based on registration
            if (model.CompanyUrl == "" || model.CompanyUrl == null)
            {
                SendEmail(model, "Email id has been created");
            }
            else
            {
                SendEmail(model, "ICon HR Registration has been Sucessfull");
            }
            if (result > 0)
            {
                return(Request.CreateResponse(HttpStatusCode.Accepted, new { Result = "Success" }));
            }

            return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "error"));
        }
Exemplo n.º 2
0
        // GET api/<controller>
        public IEnumerable <CompanyDetailModel> Get()
        {
            int mgrId = base.ReportingManagerId;

            return(_companyDetailsService.GetCompanyDetails());
        }