public async Task <ActionResult> Create(TemplatesType collection) { try { ModelState.Remove("Id"); if (ModelState.IsValid) { if (collection.Id == Guid.Empty) { await APIHelpers.PostAsync <TemplatesType>("api/TemplateType/Post", collection); TempData["sucess"] = TemplateTypeResources.create; } else { await APIHelpers.PutAsync <TemplatesType>("api/TemplateType/Put", collection); TempData["sucess"] = TemplateResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { throw; } }
public async Task <ActionResult> Create(Interviews model) { try { //var c = Request["CandidateId"]; var stime = Request["Stime"]; var sdate = Request["Sdate"]; DateTime time = Convert.ToDateTime(DateTime.ParseExact(sdate, "MM/dd/yyyy", null) + DateTime.Parse(stime).TimeOfDay); ModelState.Remove("Id"); ModelState.Remove("ScheduleTime"); if (ModelState.IsValid) { model.ScheduleTime = time; if (model.Id == Guid.Empty) { await APIHelpers.PostAsync <Interviews>("api/Interview/Post", model); TempData["sucess"] = InterviewResources.create; } else { await APIHelpers.PutAsync <Interviews>("api/Interview/Put", model); TempData["sucess"] = InterviewResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(States collection) { try { // TODO: Add insert logic here ModelState.Remove("Id"); if (ModelState.IsValid) { if (collection.Id == Guid.Empty) { await APIHelpers.PostAsync <States>("api/State/Post", collection); TempData["sucess"] = StateResources.create; } else { await APIHelpers.PutAsync <States>("api/State/Put", collection); TempData["sucess"] = StateResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(Skills collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here if (collection.Id == Guid.Empty) { await APIHelpers.PostAsync <Skills>("api/Skill/Post", collection); TempData["sucess"] = SkillsResources.create; } else { await APIHelpers.PutAsync <Skills>("api/Skill/Put", collection); TempData["sucess"] = SkillsResources.update; } return(RedirectToAction("Index")); } else { return(View(collection)); } } catch (Exception ex) { TempData["error"] = CommonResources.error; return(RedirectToAction("AccessDenied", "Error")); } }
public async Task <ActionResult> ApproveLeave(Guid id, string email) { try { var data = await APIHelpers.GetAsync <bool>("api/Leave/ApproveLeaves/" + id); if (data == true) { var emp = await APIHelpers.GetAsync <Employee>("api/Employee/GetEmployee?Email=" + email); var leave = await APIHelpers.GetAsync <Leave>("api/Leave/Get/" + id); //emp.AvailableLeaves = emp.AvailableLeaves - (leave.To.Day - leave.From.Day); await APIHelpers.PutAsync <Employee>("api/Employee/Put", emp); var subject = "Leave"; var body = "Congratulations!! Your Leave has been Approved."; //CommonHelper.SendMail(email, subject, body); return(RedirectToAction("GetPendingLeave", "Leave")); } else { return(HttpNotFound()); } } catch (Exception ex) { throw; } }
public async Task <ActionResult> Create(Interviewers model) { try { var fromtime = Request["FromTime"]; var totime = Request["ToTime"]; //var ftime = TimeSpan.Parse(fromtime, CultureInfo.InvariantCulture); ModelState.Remove("FromTime"); ModelState.Remove("ToTime"); ModelState.Remove("Id"); if (ModelState.IsValid) { model.FromTime = DateTime.Parse(fromtime).TimeOfDay; model.ToTime = DateTime.Parse(totime).TimeOfDay; if (model.Id == Guid.Empty) { await APIHelpers.PostAsync <Interviewers>("api/Interviewer/Post", model); TempData["sucess"] = InterviewerResources.create; } else { await APIHelpers.PutAsync <Interviewers>("api/Interviewer/Put", model); TempData["sucess"] = InterviewerResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Profile(EmployeeUserViewModel collection) { try { ViewBag.Department = await APIHelpers.GetAsync <List <Departments> >("api/Department/GetDepartments"); ViewBag.Skills = await APIHelpers.GetAsync <List <Skills> >("api/Skill/GetSkills"); string skills = string.Join(",", Request["Skill"]); collection.Skills = skills; await APIHelpers.PutAsync <Employee>("api/Employee/Put", collection); TempData["sucess"] = EmployeeResources.update; //string dob = Request["BirthDate"]; //string skills = string.Join(",", Request["Skill"]); //ModelState.Remove("BirthDate"); //ModelState.Remove("LeaveBalance"); ////var month = (13 - DateTime.Now.Month) * 1.5; //if (ModelState.IsValid) //{ // collection.BirthDate = DateTime.ParseExact(dob, "dd/MMM/yyyy", null); // collection.LeaveBalance = Convert.ToDecimal(15); // collection.Skills = skills; // // TODO: Add insert logic here // if (collection.Id == Guid.Empty) // { // var user = new ApplicationUser { RoleId = collection.RoleId, UserName = collection.Email, IsSuperAdmin = false, ParentUserID = Guid.Parse("06644856-45f6-4c78-9c19-60781abba7e3"), Email = collection.Email, FirstName = "", LastName = "", UserStatus = 0 }; // collection.UserId = Guid.Parse(user.Id); // var result = await UserManager.CreateAsync(user, collection.Password); // if (result.Succeeded) // { // await APIHelpers.PostAsync<Employee>("api/Employee/Post", collection); // TempData["sucess"] = EmployeeResources.create; // } // } // else // { // await APIHelpers.PutAsync<Employee>("api/Employee/Put", collection); // TempData["sucess"] = EmployeeResources.update; // } return(View("Profile", collection)); //} //else //{ // return View(collection); //} } catch (Exception ex) { TempData["error"] = CommonResources.error; return(RedirectToAction("AccessDenied", "Error")); } }
public async Task <ActionResult> Create(HttpPostedFileBase[] Documents, ProjectTeamViewModel collection) { try { string employees = string.Join(",", Request["Employees"]); ModelState.Remove("Id"); ModelState.Remove("Documents"); ModelState.Remove("EmployeeId"); ModelState.Remove("CurrentlyWorking"); if (ModelState.IsValid) { collection.Documents = ""; //foreach (HttpPostedFileBase file in Documents) //{ // if (file != null) // { // var filename = Path.GetFileName(file.FileName); // collection.Documents = collection.Documents + " " + filename; // var serverpath = Path.Combine(Server.MapPath("~/ProjectDocuments/") + filename); // file.SaveAs(serverpath); // } //} //ViewBag.Employees = await APIHelpers.GetAsync<List<Employee>>("api/Employee/GetEmployees"); For when redirect to same view this statement is ndeeded for Employee Dropdown if (collection.Id == Guid.Empty) { //var data = await APIHelpers.PostAsync<Projects>("api/Project/Post", collection); //collection.Id = data.Id; await APIHelpers.PostAsync <Projects>("api/Project/Post", collection); TempData["sucess"] = ProjectResources.create; } else { collection.EmployeeId = employees; await APIHelpers.PutAsync <Projects>("api/Project/Put", collection); TempData["sucess"] = ProjectResources.update; } return(RedirectToAction("Index")); //return View("Create", collection); //For redirect to same view } else { return(View(collection)); } } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Edit(RolePermission role) { try { await APIHelpers.PutAsync <RolePermission>("api/RolePermission/Put", role); return(RedirectToAction("Index")); } catch (Exception ex) { throw; } }
public async Task <ActionResult> Create(Notifications collection) { try { ModelState.Remove("From"); ModelState.Remove("To"); if (ModelState.IsValid) { collection.From = DateTime.Now.Date; var todate = Convert.ToDouble(Request["Duration"]); if (todate == 0) { TempData["error"] = NotificationResources.duration; return(View(collection)); } else { collection.To = DateTime.Now.Date.AddDays(todate - 1); } //collection.To = DateTime.Now.Date.AddDays(Convert.ToDouble(Request["Duration"])); // TODO: Add insert logic here if (collection.Id == Guid.Empty) { await APIHelpers.PostAsync <Notifications>("api/Notification/Post", collection); TempData["sucess"] = NotificationResources.create; } else { await APIHelpers.PutAsync <Notifications>("api/Notification/Put", collection); TempData["sucess"] = NotificationResources.update; } return(RedirectToAction("Index")); } else { return(View(collection)); } } catch (Exception ex) { TempData["error"] = CommonResources.error; return(RedirectToAction("AccessDenied", "Error")); } }
public async Task <ActionResult> Create(CandidateViewModel model) { try { string dt = Request["Birthdate"]; ModelState.Remove("Id"); ModelState.Remove("Experience"); ModelState.Remove("BirthDate"); model.Skills = string.Join(",", Request["Skill"]); model.Technology = string.Join(",", Request["Technology"]); var d = decimal.Parse("20.03"); var d2 = Convert.ToDecimal("20.03"); if (ModelState.IsValid) { model.BirthDate = DateTime.ParseExact(dt, "MM/dd/yyyy", null); var month = Convert.ToDecimal(Request["Month"]); if (month < 10) { model.Experience = Convert.ToDecimal(Request["Year"] + "." + "0" + Request["Month"]); } else { model.Experience = Convert.ToDecimal(Request["Year"] + "." + Request["Month"]); } if (model.Id == Guid.Empty) { await APIHelpers.PostAsync <CandidateViewModel>("api/Candidate/Post", model); TempData["sucess"] = CandidateResources.create; } else { await APIHelpers.PutAsync <CandidateViewModel>("api/Candidate/Put", model); TempData["sucess"] = CandidateResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(Openings model) { try { ModelState.Remove("Id"); ModelState.Remove("CreatedDate"); ModelState.Remove("Experience"); if (ModelState.IsValid) { var month = Convert.ToDecimal(Request["Month"]); if (month < 10) { month = Convert.ToDecimal("0" + month); } else { month = Convert.ToDecimal(Request["Month"]); } var exp = Request["Year"] + "." + month; model.Experience = Convert.ToDecimal(exp); model.Skills = string.Join(",", Request["Skill"]); if (model.Id == Guid.Empty) { model.CreatedDate = DateTime.Now.Date; //model.Skills = string.Join(",", Request["Skill"]); var data = await APIHelpers.PostAsync <Openings>("api/Openings/Post", model); TempData["sucess"] = OpeningResources.create; } else { var data = await APIHelpers.PutAsync <Openings>("api/Openings/Put", model); TempData["sucess"] = OpeningResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(HttpPostedFileBase[] Attachment, Leave collection) { try { string from = Request["From"]; string to = Request["To"]; ModelState.Remove("Attachment"); ModelState.Remove("Id"); ModelState.Remove("EmployeeId"); ModelState.Remove("From"); ModelState.Remove("To"); if (ModelState.IsValid) { collection.From = DateTime.ParseExact(from, "MM/dd/yyyy", null); collection.To = DateTime.ParseExact(to, "MM/dd/yyyy", null); collection.AssignTo = ""; collection.EmployeeId = Guid.Parse(EmployeeManagementSystem.Helper.CommonHelper.GetUserId()); collection.LeaveStatus = Enums.LeaveStatus.Pending; collection.Attachment = ""; foreach (HttpPostedFileBase file in Attachment) { if (file.FileName.Contains(".pdf") || file.FileName.Contains(".jpg") || file.FileName.Contains(".JPEG")) { if (file != null) { var filename = Path.GetFileName(file.FileName); collection.Attachment = collection.Attachment + " " + filename; var serverpath = Path.Combine(Server.MapPath("~/LeaveImage/") + filename); file.SaveAs(serverpath); } } else { TempData["error"] = LeaveResources.FileError; return(View()); } } // TODO: Add insert logic here if (collection.Id == Guid.Empty) { await APIHelpers.PostAsync <Leave>("api/Leave/Post", collection); var role = await _customerService.GetHR(); string temp = String.Join(",", role); string subject = "Request For Leave"; var body = await _customerService.GetLeaveTemplate(); var store = new UserStore <ApplicationUser>(new ApplicationDbContext()); var userManager = new UserManager <ApplicationUser>(store); ApplicationUser user = userManager.FindByNameAsync(User.Identity.Name).Result; var content = body.TemplateContent; content.Replace("###CurrentUser###", "Dhaval"); content = Regex.Replace(content, "###CurrentUser###", user.FirstName + " " + user.LastName); content = Regex.Replace(content, "###FromDate###", collection.From.ToString()); content = Regex.Replace(content, "###ToDate###", collection.To.ToString()); content = Regex.Replace(content, "###LeaveReason###", collection.Message); //CommonHelper.SendMail(temp, subject, content); TempData["sucess"] = LeaveResources.create; } else { await APIHelpers.PutAsync <Leave>("api/Leave/Put", collection); TempData["sucess"] = LeaveResources.update; } return(RedirectToAction("Index")); } else { return(View(collection)); } } catch (Exception ex) { TempData["error"] = CommonResources.error; return(RedirectToAction("AccessDenied", "Error")); } }
public async Task <ActionResult> Create(EmployeeUserViewModel collection) { try { ViewBag.Department = await APIHelpers.GetAsync <List <Departments> >("api/Department/GetDepartments"); ViewBag.Skills = await APIHelpers.GetAsync <List <Skills> >("api/Skill/GetSkills"); ViewBag.Roles = _applicationDbContext.Roles.ToList(); string skills = string.Join(",", Request["Skill"]); ModelState.Remove("BirthDate"); ModelState.Remove("JoiningDate"); ModelState.Remove("LeaveBalance"); ModelState.Remove("OtherContact"); ModelState.Remove("Skills"); //var month = (13 - DateTime.Now.Month) * 1.5; if (collection.Id == Guid.Empty) { if (ModelState.IsValid) { collection.Skills = skills; string dob = Request["BirthDate"]; collection.BirthDate = DateTime.ParseExact(dob, "MM/dd/yyyy", null); string join = Request["JoiningDate"]; collection.JoiningDate = DateTime.ParseExact(join, "MM/dd/yyyy", null); var user = new ApplicationUser { RoleId = collection.RoleId, UserName = collection.Email, IsSuperAdmin = false, ParentUserID = Guid.Parse("06644856-45f6-4c78-9c19-60781abba7e3"), Email = collection.Email, FirstName = "", LastName = "", UserStatus = 0 }; collection.UserId = Guid.Parse(user.Id); var account = await UserManager.CreateAsync(user, collection.Password); if (account.Succeeded) { var result = await PostAsync <EmployeeUserViewModel>("api/Employee/Post", collection); if (result) { TempData["sucess"] = EmployeeResources.create; return(RedirectToAction("Index")); } else { var delete = await UserManager.DeleteAsync(CommonHelper.GetUserById(user.Id)); TempData["error"] = CommonResources.error; return(View(collection)); } } else { string msg = ""; foreach (var error in account.Errors) { ModelState.AddModelError("", error); msg += error + Environment.NewLine; } //await APIHelpers.DeleteAsync<bool>("api/Employee/Delete/" + data.Id); TempData["error"] = msg; return(View(collection)); } } else { return(View(collection)); } } else { ModelState.Remove("Password"); ModelState.Remove("Email"); if (ModelState.IsValid) { string dob = Request["BirthDate"]; collection.BirthDate = DateTime.ParseExact(dob, "MM/dd/yyyy", null); collection.Skills = skills; await APIHelpers.PutAsync <Employee>("api/Employee/Put", collection); TempData["sucess"] = EmployeeResources.update; } else { return(RedirectToAction("Edit", new RouteValueDictionary( new { action = "Edit", Id = collection.Id }))); //return View(collection); } } return(RedirectToAction("Index")); } catch (Exception ex) { TempData["error"] = CommonResources.error; return(RedirectToAction("AccessDenied", "Error")); } }