コード例 #1
0
        public bool AddOrUpdateUserEmploymentDetails(GetUserEmploymentDetails userVM)
        {
            string username = HttpContext.Current.User.Identity.Name;

            userVM.UserId = _userDL.GetUserId(username);
            UserEmploymentDetailsVM user = _userDL.GetUserEmploymentDetails(userVM.UserId);

            if (user.UserId > 0)
            {
                return(_userDL.UpdateUserEmploymentDetails(userVM));
            }
            return(_userDL.AddUserEmployementDetails(userVM));
        }
コード例 #2
0
        public ActionResult UserEmploymentDetails()
        {
            ViewData["Username"] = HttpContext.Request.Cookies.Get("username").Value;
            string token = HttpContext.Request.Cookies.Get("token").Value;

            if (TempData.Peek("EmploymentDropdowns") == null)
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://localhost:52778/user/");
                    client.DefaultRequestHeaders.Add("Authorization", "bearer " + token);
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.ConnectionClose = true;
                    var response = client.GetAsync("getEmploymentDropdowns");
                    var result   = response.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        var objString = result.Content.ReadAsStringAsync().Result;
                        var obj       = JsonConvert.DeserializeObject <EmploymentDropdowns>(objString);
                        TempData["EmploymentDropdowns"] = obj;
                    }
                }
            }
            ViewBag.Contracts       = new SelectList((TempData.Peek("EmploymentDropdowns") as EmploymentDropdowns).Contracts, "ContractId", "ContractType");
            ViewBag.EmployeeStatues = new SelectList((TempData.Peek("EmploymentDropdowns") as EmploymentDropdowns).Statuses, "EmployeeStatusId", "EmployeeStatusType");
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:52778/user/");
                client.DefaultRequestHeaders.Add("Authorization", "bearer " + token);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.ConnectionClose = true;
                var response = client.GetAsync("getEmploymentDetails");
                var result   = response.Result;
                if (result.IsSuccessStatusCode)
                {
                    var objString = result.Content.ReadAsStringAsync().Result;
                    var obj       = JsonConvert.DeserializeObject <UserEmploymentDetailsVM>(objString);
                    GetUserEmploymentDetails user = new GetUserEmploymentDetails()
                    {
                        Company          = obj.Company,
                        ContractId       = obj.ContractId,
                        CreditScore      = obj.CreditScore,
                        EmployeeStatusId = obj.EmployeeStatusId,
                        Salary           = obj.Salary
                    };
                    return(View(user));
                }
            }
            return(View());
        }
コード例 #3
0
ファイル: UserDL.cs プロジェクト: Dharan21/l2g_API
        public bool AddUserEmployementDetails(GetUserEmploymentDetails userVM)
        {
            l2g_tbl_UserEmployeementDetails user = MappingConfig.GetUserEmploymentDetailsToDataEntity(userVM);

            user.CreatedDate = DateTime.Now;
            try
            {
                db.l2g_tbl_UserEmployeementDetails.Add(user);
                db.SaveChanges();
            }
            catch (Exception) {
                return(false);
            }
            return(true);
        }
コード例 #4
0
ファイル: UserDL.cs プロジェクト: Dharan21/l2g_API
 public bool UpdateUserEmploymentDetails(GetUserEmploymentDetails userVM)
 {
     //l2g_tbl_UserEmployeementDetails user = MappingConfig.GetUserEmploymentDetailsToDataEntity(userVM);
     try
     {
         l2g_tbl_UserEmployeementDetails userEntity = db.l2g_tbl_UserEmployeementDetails.Where(x => x.UserId == userVM.UserId).First();
         userEntity.Company          = userVM.Company;
         userEntity.ContractId       = userVM.ContractId;
         userEntity.CreditScore      = userVM.CreditScore;
         userEntity.EmployeeStatusId = userVM.EmployeeStatusId;
         userEntity.Salary           = userVM.Salary;
         db.SaveChanges();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
コード例 #5
0
ファイル: UserController.cs プロジェクト: Dharan21/l2g_API
 public IHttpActionResult AddEmploymentDetails(GetUserEmploymentDetails userVM)
 {
     if (ModelState.IsValid)
     {
         bool isSuccess = _userBL.AddOrUpdateUserEmploymentDetails(userVM);
         if (isSuccess)
         {
             return(Ok());
         }
         else
         {
             return(InternalServerError());
         }
     }
     else
     {
         var validationResult = CustomDataAnnotation.ValidateEntity <GetUserEmploymentDetails>(userVM);
         return(BadRequest(JsonConvert.SerializeObject(validationResult.ValidationErrors)));
     }
 }
コード例 #6
0
ファイル: MappingConfig.cs プロジェクト: Dharan21/l2g_API
        public static l2g_tbl_UserEmployeementDetails GetUserEmploymentDetailsToDataEntity(GetUserEmploymentDetails userVM)
        {
            l2g_tbl_UserEmployeementDetails user = new l2g_tbl_UserEmployeementDetails()
            {
                UserId           = userVM.UserId,
                Company          = userVM.Company,
                Salary           = userVM.Salary,
                CreditScore      = userVM.CreditScore,
                EmployeeStatusId = userVM.EmployeeStatusId,
                ContractId       = userVM.ContractId
            };

            return(user);
        }
コード例 #7
0
        public async System.Threading.Tasks.Task <ActionResult> UserEmploymentDetailsAsync(GetUserEmploymentDetails userVM)
        {
            if (ModelState.IsValid)
            {
                string token = HttpContext.Request.Cookies.Get("token").Value;
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://localhost:52778/user/");
                    client.DefaultRequestHeaders.Add("Authorization", "bearer " + token);
                    var                 content  = JsonConvert.SerializeObject(userVM);
                    HttpContent         c        = new StringContent(content, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = await client.PostAsync("addEmploymentDetails", c);

                    if (response.IsSuccessStatusCode)
                    {
                        return(RedirectToAction("UserBankDetails"));
                    }
                    else
                    {
                        if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                        {
                            return(RedirectToAction("Login", "Auth"));
                        }
                        else
                        {
                            ViewData["Error"] = "Unknown Error Occured!";
                        }
                        return(View());
                    }
                }
            }
            ViewData["Username"] = HttpContext.Request.Cookies.Get("username").Value;
            return(View());
        }