public void Edit() { var before = new Employments(this.Session).Extent().ToArray(); var employer = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var personOverviewPage = this.people.Select(this.employee); var page = personOverviewPage.SelectPartyRelationship(this.editPartyRelationship); page.FromDate.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ThroughDate.Set(DateTimeFactory.CreateDate(2018, 12, 22).AddYears(1)) .Save.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new Employments(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, this.editPartyRelationship.FromDate.Date.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).AddYears(1).Date, this.editPartyRelationship.ThroughDate.Value.Date.ToUniversalTime().Date); Assert.Equal(employer, this.editPartyRelationship.Employer); Assert.Equal(this.employee, this.editPartyRelationship.Employee); }
public async Task DeleteEmployee(Employee employee) { var teritories = await Teritories.List(t => t.EmployeeId == employee.EmployeeId); var orders = await Orders.List(o => o.EmployeeId == employee.EmployeeId); var employments = await Employments.List(e => e.EmployeeId == employee.EmployeeId); foreach (var item in orders) { var orderdetails = await _orderDetails.List(o => o.OrderId == item.OrderId); await _orderDetails.DeleteRange(orderdetails); } await _orders.DeleteRange(orders); await _teritories.DeleteRange(teritories); await Employments.DeleteRange(employments); await Employees.Delete(employee); }
// GET: Employment public ActionResult EmploymentInfo() { if (Session["Tracker"] == null) { return(RedirectToAction("ApplicantInfo", "Applicant")); } var tracker = (Guid)Session["Tracker"]; var employment = new Employments(); var existingPrimary = _context.Applicants.FirstOrDefault(x => x.ApplicantTracker == tracker).Employment.FirstOrDefault(x => x.IsPrimary); if (existingPrimary != null) { employment.PrimaryEmployer = Mapper.Map <EmploymentVM>(existingPrimary); } var existingPrevious = _context.Applicants.FirstOrDefault(x => x.ApplicantTracker == tracker).Employment.FirstOrDefault(x => x.IsPrimary == false); if (existingPrevious != null) { employment.PreviousEmployer = Mapper.Map <EmploymentVM>(existingPrevious); } return(View(employment)); }
public void Create() { var before = new Employments(this.Session).Extent().ToArray(); var employer = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); this.people.Table.DefaultAction(this.employee); var employmentEditComponent = new PersonOverviewComponent(this.people.Driver).PartyrelationshipOverviewPanel.Click().CreateEmployment(); employmentEditComponent.FromDate .Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ThroughDate.Set(DateTimeFactory.CreateDate(2018, 12, 22).AddYears(1)) .SAVE.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new Employments(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length + 1); var partyRelationship = after.Except(before).First(); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, partyRelationship.FromDate.Date.ToUniversalTime().Date); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).AddYears(1).Date, partyRelationship.ThroughDate.Value.Date.ToUniversalTime().Date); Assert.Equal(employer, partyRelationship.Employer); Assert.Equal(this.employee, partyRelationship.Employee); }
public JsonResult Get(int pageIndex, int pageSize, string pageOrder, string name) { var list = Employments.Get(pageIndex, pageSize, pageOrder, name); int total = Employments.Count(name); int totalPage = (int)Math.Ceiling((decimal)total / pageSize); if (pageSize > total) { pageSize = total; } if (list.Count < pageSize) { pageSize = list.Count; } JsonResult result = new JsonResult() { Data = new { TotalPages = totalPage, PageIndex = pageIndex, PageSize = pageSize, Rows = list }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return(result); }
public ActionResult DeleteConfirmed(int id) { Employments employments = db.Employments.Find(id); db.Employments.Remove(employments); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Employment_id,Person_Id,End_date,Start_date,Assignments")] Employments employments) { if (ModelState.IsValid) { db.Entry(employments).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Edit/1")); } ViewBag.Person_Id = new SelectList(db.Persons, "Person_id", "FirstName", employments.Person_Id); return(View(employments)); }
public IActionResult PostEmployments([FromForm] Employments employments) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Employments.Add(employments); _context.SaveChanges(); return(CreatedAtAction("GetEmployments", new { id = employments.EmploymentId }, employments)); }
public ActionResult Create([Bind(Include = "Employment_id,Person_Id,End_date,Start_date,Assignments")] Employments employments) { if (ModelState.IsValid) { db.Employments.Add(employments); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Person_Id = new SelectList(db.Persons, "Person_id", "FirstName", employments.Person_Id); return(View(employments)); }
public async Task <int> AddEmployment(int id) { var employee = await Employees.GetById(id, new string[1] { "Employments" }); var newEmployment = new Employment() { HireDate = DateTime.Now.Date, EmployeeId = employee.EmployeeId }; return(await Employments.Add(newEmployment)); }
private static Employment FindEmployment(ScheduleClasses.View view, Employments items, string name, ScheduleTime time) { switch (view) { case ScheduleClasses.View.Teacher: return(items.Teachers.GetItem(name, time)); case ScheduleClasses.View.Group: return(items.Groups.GetItem(name, time)); case ScheduleClasses.View.Room: return(items.Rooms.GetItem(name, time)); default: return(null); } }
//View products time of put public void EmploymentPutMaker(ViewEmployments employments, Employments employmentsInDb) { employmentsInDb.Price = employments.Price; employmentsInDb.EmploymentName = employments.EmploymentName; employmentsInDb.CustomerId = employments.CustomerId; employmentsInDb.Customer = employments.Customer; //employments.GuId = employmentsInDb.GuId; employmentsInDb.Schedules = (ICollection <Schedules>)employments.ViewSchedules; for (var i = 0; i < employmentsInDb.Schedules.Count; i++) { CreateViewSchedules(employmentsInDb.Schedules.ElementAt(i)); } }
public void Edit() { var employer = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var employee = new PersonBuilder(this.Session).WithLastName("employee").Build(); // Delete all existing for the new one to be in the first page of the list. foreach (PartyRelationship partyRelationship in employer.PartyRelationshipsWhereParty) { partyRelationship.Delete(); } this.Session.Derive(); this.Session.Commit(); var editPartyRelationship = new EmploymentBuilder(this.Session) .WithEmployee(employee) .WithEmployer(employer) .Build(); this.Session.Derive(); this.Session.Commit(); var before = new Employments(this.Session).Extent().ToArray(); this.organisationListPage.Table.DefaultAction(employer); var organisationOverview = new OrganisationOverviewComponent(this.organisationListPage.Driver); var partyRelationshipOverview = organisationOverview.PartyrelationshipOverviewPanel.Click(); partyRelationshipOverview.Table.DefaultAction(editPartyRelationship); var partyRelationshipEdit = new EmploymentEditComponent(organisationOverview.Driver); partyRelationshipEdit .FromDate.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ThroughDate.Set(DateTimeFactory.CreateDate(2018, 12, 22).AddYears(1)) .SAVE.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new Employments(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, this.editPartyRelationship.FromDate.Date.ToUniversalTime().Date); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).AddYears(1).Date, this.editPartyRelationship.ThroughDate.Value.Date.ToUniversalTime().Date); Assert.Equal(employer, editPartyRelationship.Employer); Assert.Equal(employee, editPartyRelationship.Employee); }
// GET: Employments/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employments employments = db.Employments.Find(id); if (employments == null) { return(HttpNotFound()); } return(View(employments)); }
public async Task <int> DeleteEmployment(int employeeId, int employmentId) { var employees = await Employees.List(new string[1] { "Employments" }); var employee = employees.SingleOrDefault(e => e.EmployeeId == employeeId); if (employee == null) { throw new NullReferenceException("Employee not found"); } return(await Employments.Delete(employee.Employments.Single(e => e.EmploymentId == employmentId))); }
// GET: Employments/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employments employments = db.Employments.Find(id); if (employments == null) { return(HttpNotFound()); } ViewBag.Person_Id = new SelectList(db.Persons, "Person_id", "FirstName", employments.Person_Id); return(View(employments)); }
public ActionResult Edit(Employment employment) { try { employment.LastUpdate = DateTime.Now; ViewBag.Success = true; Employments.Update(employment); } catch (Exception ex) { SetErrors(ex); } return(RedirectToAction("Index")); }
public ActionResult EmploymentInfo(Employments vm) { if (Session["Tracker"] == null) { return(RedirectToAction("ApplicantInfo", "Applicant")); } var tracker = (Guid)Session["Tracker"]; if (ModelState.IsValid) { var applicant = _context.Applicants.FirstOrDefault(x => x.ApplicantTracker == tracker); var existingEmployment = applicant.Employment.FirstOrDefault(x => x.IsPrimary); if (existingEmployment != null) { Mapper.Map(vm.PrimaryEmployer, existingEmployment); _context.Entry(existingEmployment).State = EntityState.Modified; } else { var newEmployment = Mapper.Map <Employment>(vm.PrimaryEmployer); newEmployment.IsPrimary = true; applicant.Employment.Add(newEmployment); } var existingPrevious = applicant.Employment.FirstOrDefault(x => x.IsPrimary == false); if (existingPrevious != null) { Mapper.Map(vm.PreviousEmployer, existingPrevious); _context.Entry(existingPrevious).State = EntityState.Modified; } else { var newEmployment = Mapper.Map <Employment>(vm.PreviousEmployer); newEmployment.IsPrimary = false; applicant.Employment.Add(newEmployment); } _context.SaveChanges(); return(RedirectToAction("VehicleInfo", "Vehicle")); } return(View()); }
//Employments to View public ViewEmployments CreateEmploymentsViewModel(Employments requestEmployments) { var empl = new ViewEmployments { Customer = requestEmployments.Customer, EmploymentName = requestEmployments.EmploymentName, CustomerId = requestEmployments.CustomerId, MakingTime = requestEmployments.MakingTime, Price = requestEmployments.Price, GuId = requestEmployments.GuId }; foreach (var schedule in requestEmployments.Schedules) { var viewSchedules = CreateViewSchedules(schedule); empl.ViewSchedules.Add(viewSchedules); } return(empl); }
//View to Employments public Employments CreateEmploymentsModelFromDb(ViewEmployments virweEmployments) { var employments = new Employments { Customer = virweEmployments.Customer, EmploymentName = virweEmployments.EmploymentName, CustomerId = virweEmployments.CustomerId, Price = virweEmployments.Price, MakingTime = virweEmployments.MakingTime, GuId = Guid.NewGuid() }; foreach (var employmentsViewSchedule in virweEmployments.ViewSchedules) { var dbSchedules = CreateDbSchedules(employmentsViewSchedule); employments.Schedules.Add(dbSchedules); } return(employments); }
public ActionResult Edit(int id) { Employment employment; employment = Employments.GetByID(id); if (employment.EducationCoursesText != null) { employment.EducationCoursesText = employment.EducationCoursesText.Replace("\r\n", "<br/>"); } if (employment.ResumeText != null) { employment.ResumeText = employment.ResumeText.Replace("\r\n", "<br/>"); } if (employment.StudyText != null) { employment.StudyText = employment.StudyText.Replace("\r\n", "<br/>"); } return(View(model: employment)); }
public JsonResult Delete(int id) { var jsonSuccessResult = new JsonSuccessResult(); try { Employments.Delete(id); jsonSuccessResult.Success = true; } catch (Exception ex) { jsonSuccessResult.Errors = new string[] { ex.Message }; jsonSuccessResult.Success = false; } return(new JsonResult() { Data = jsonSuccessResult }); }
public ActionResult EmploymentInfo() { var tracker = (Guid)Session["Tracker"]; var employment = new Employments(); var existingPrimary = _applicantService.GetApplicantsByTraker(tracker).Employment.FirstOrDefault(x => x.IsPrimary); if (existingPrimary != null) { employment.PrimaryEmployer = Mapper.Map <EmploymentVM>(existingPrimary); } var existingPrevious = _applicantService.GetApplicantsByTraker(tracker).Employment.FirstOrDefault(x => x.IsPrimary == false); if (existingPrevious != null) { employment.PreviousEmployer = Mapper.Map <EmploymentVM>(existingPrevious); } return(View(employment)); }
public IHttpActionResult PutEmployments(Employments obj) { Employments empl = principal.Employments.Where(x => x.EmploymentID == obj.EmploymentID).FirstOrDefault(); if (empl.EmploymentTypeID != obj.EmploymentTypeID) { var EmploymentEmployeeDuplicate = principal.Employments .Where(x => !x.IsDeleted && obj.EmploymentTypeID == x.EmploymentTypeID && obj.EmployeeID == x.EmployeeID) .FirstOrDefault(); if (EmploymentEmployeeDuplicate != null) { return(Content(HttpStatusCode.BadRequest, ExceptionsMapper[ExceptionType.EmployeeEmploymentsDuplicate])); } } if (empl.BankAccountNumber != obj.BankAccountNumber) { var EmployeeWithSameBankAccountNumber = principal.Employments .Where(x => !x.IsDeleted && x.EmployeeID != obj.EmployeeID && x.BankAccountNumber == obj.BankAccountNumber) .FirstOrDefault(); if (EmployeeWithSameBankAccountNumber != null) { return(Content(HttpStatusCode.BadRequest, ExceptionsMapper[ExceptionType.BankAccountNumberUniquenessViolation])); } } empl.HireDate = obj.HireDate; empl.CurrentSalary = obj.CurrentSalary; empl.EmploymentTypeID = obj.EmploymentTypeID; empl.BankAccountNumber = obj.BankAccountNumber; empl.BankID = obj.BankID; principal.SaveChanges(); return(Ok(new { EmploymentID = empl.EmploymentID, EmployeeID = empl.EmployeeID, EmploymentTypeID = empl.EmploymentTypeID })); }
public ActionResult EmploymentInfo(Employments employments) { var tracker = (Guid)Session["Tracker"]; if (ModelState.IsValid) { var applicant = _applicantService.GetApplicantsByTraker(tracker); var existingEmployment = applicant.Employment.FirstOrDefault(x => x.IsPrimary); if (existingEmployment != null) { _employmentService.Update(existingEmployment); } else { var newEmployment = Mapper.Map <EmploymentDto>(employments.PrimaryEmployer); newEmployment.IsPrimary = true; _employmentService.Create(newEmployment); } var existingPrevious = applicant.Employment.FirstOrDefault(x => x.IsPrimary == false); if (existingPrevious != null) { var newEmployment = Mapper.Map(employments.PreviousEmployer, existingPrevious); _employmentService.Update(existingPrevious); } else { var newEmployment = Mapper.Map <EmploymentDto>(employments.PreviousEmployer); newEmployment.IsPrimary = false; _employmentService.Create(newEmployment); } return(RedirectToAction("VehicleInfo", "Vehicle")); } return(View()); }
public void Employ(Employment employment, bool force = false) { Requires.NotNull(employment, nameof(employment)); Requires.NotNull(Employments, nameof(Employments)); if (IsOffice) { throw new InvalidOperationException(); // TODO: specify text } if (!IsEmployee) { if (force) { MakeEmployee(); } else { throw new InvalidOperationException(); // TODO: specify text } } Employments.Add(employment); }
public void Create() { var employer = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var employee = new PersonBuilder(this.Session).WithLastName("employee").Build(); // Delete all existing for the new one to be in the first page of the list. foreach (PartyRelationship relationship in employer.PartyRelationshipsWhereParty) { relationship.Delete(); } this.Session.Derive(); this.Session.Commit(); var before = new Employments(this.Session).Extent().ToArray(); var page = this.organisationListPage.Select(employer).NewEmployment(); page.FromDate.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ThroughDate.Set(DateTimeFactory.CreateDate(2018, 12, 22).AddYears(1)) .Employee.Set(employee.PartyName) .Save.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new Employments(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length + 1); var partyRelationship = after.Except(before).First(); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, partyRelationship.FromDate.Date.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).AddYears(1).Date, partyRelationship.ThroughDate.Value.Date.ToUniversalTime().Date); Assert.Equal(employer, partyRelationship.Employer); Assert.Equal(employee, partyRelationship.Employee); }
public ActionResult Index(Employment employment) { try { employment.DateTime = employment.LastUpdate = DateTime.Now; employment.EmploymentStatus = EmploymentStatus.NotChecked; var files = Utilities.SaveFiles(Request.Files, Utilities.GetNormalFileName(employment.NationalCode), StaticPaths.ResumeFiles); if (files.Count > 0) { employment.ResumeFile = files[0].Title; } Employments.Insert(employment); ViewBag.IsSuccess = true; // اطلاع رسانی به مدیر #region Apprise Admin string body = "مدیریت محترم، در بخش استخدام در آنلاین استور، فردی رزومه خود را ارسال کرده است:"; body += "<br/>"; body += String.Format("ایمیل: {0} <br/> نام و نام خانوادگی: {1}", employment.Email, employment.FirstName + " " + employment.LastName); EmailServices.NotifyAdminsByEmail(AdminEmailType.NewEmployment, body, null); #endregion Apprise Admin EmailServices.DeliveryEmploymentInfo(employment.Email, employment.FirstName + " " + employment.LastName, UserID); } catch { ViewBag.IsSuccess = false; } return(View(employment)); }
public IHttpActionResult PostEmployments(Employments obj) { var employmentSameBankAccount = principal.Employments .Where(x => x.BankAccountNumber == obj.BankAccountNumber && x.EmployeeID != obj.EmployeeID && !x.IsDeleted).FirstOrDefault(); if (employmentSameBankAccount != null) { return(Content(HttpStatusCode.BadRequest, ExceptionsMapper[ExceptionType.BankAccountNumberUniquenessViolation])); } var SameEmployment = principal.Employments .Where(x => !x.IsDeleted && x.EmployeeID == obj.EmployeeID && x.EmploymentTypeID == obj.EmploymentTypeID) .FirstOrDefault(); if (SameEmployment != null) { return(Content(HttpStatusCode.BadRequest, ExceptionsMapper[ExceptionType.EmployeeEmploymentsDuplicate])); } Employments empl = new Employments(); empl.EmployeeID = obj.EmployeeID; empl.HireDate = obj.HireDate; empl.CurrentSalary = obj.CurrentSalary; empl.EmploymentTypeID = obj.EmploymentTypeID; empl.BankAccountNumber = obj.BankAccountNumber; empl.BankID = obj.BankID; empl.IsDeleted = false; principal.Employments.Add(empl); principal.SaveChanges(); return(Ok(new { EmploymentID = empl.EmploymentID, EmployeeID = empl.EmployeeID, EmploymentTypeID = empl.EmploymentTypeID })); }
private static void SetElementView(List <ScheduleLesson> LessonsByView, string nameElementProjection, ScheduleClasses.View view, ScheduleWeeks Shedule, DataGridView table, Employments Employments, bool watchAll) { for (int Hour = 1; Hour <= Shedule.Setting.CountLessonsOfDay; Hour++) { DataGridViewRow row = CreateNewRow(table, nameElementProjection, ScheduleTime.GetHourDiscription(Hour)); for (int Week = 1, CellIndex = 2; Week <= Shedule.Setting.CountWeeksShedule; Week++) { for (int Day = 1; Day <= Shedule.Setting.CountDaysEducationWeek; Day++, CellIndex++) { //время занятия на 1-2 недели ScheduleTime Time1 = new ScheduleTime((Week)Week, (ScheduleClasses.Day)Day, Hour); //время занятия на 3-4 недели ScheduleTime Time2 = GetTimeAfterTwoWeek(Time1); //занятие на 1-2 недели ScheduleLesson item1 = Shedule.FindLessonInList(LessonsByView, Time1); //занятие на 3-4 недели ScheduleLesson item2 = Shedule.FindLessonInList(LessonsByView, Time2); string Room1 = item1 != null ? item1.Room : String.Empty; string Room2 = item2 != null ? item2.Room : String.Empty; Employment employmentCell = FindEmployment(view, Employments, nameElementProjection, Time1); string cellContent = item1 == null && item2 == null ? String.Empty : IsLessonsEqualAndNonEmpty(item1, item2) ? GetCellContentIdenticalLessons(view, item1) : GetCellContentDiffrentLessons(view, item1, item2); // задать значения ячейки в DataGridViewCell cell = row.Cells[CellIndex]; cell.Value = cellContent; cell.Tag = new SchedulePointer(Time1, Time2, Room1, Room2); // задать цвет и стиль ячейке if (cellContent != String.Empty) { cell.Style.BackColor = IsLessonsEqualAndNonEmpty(item1, item2) ? Color.LightGreen : Color.LightGreen; } if (employmentCell != null && employmentCell.Reason == ReasonEmployment.UserBlocked) { SetCellBlockedStyle(cell); } } } if (watchAll || (!watchAll && Shedule.Lessons.Where(x => x.Hour == Hour && !x.IsEmpty).Count() > 0)) { table.Rows.Add(row); } } //добавить разделитель int index = table.Rows.GetLastRow(DataGridViewElementStates.None); if (index >= 0) { table.Rows[index].DividerHeight = 3; } }