Exemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "PersonId,Name,Surname,FullName,Login,active,DictDepartmentID,DictTeamID,FormOfEmployment,TypeOfEmployment,DictJobTitleID,DictSkillID,DateTo")] Person person)
        {
            if (ModelState.IsValid)
            {
                person.DateFrom = new DateTime(1999, 1, 1);
                var test = person;
                db.Entry(person).State = EntityState.Modified;
                db.SaveChanges();

                var DateTo = new DateTime(1999, 1, 1);
                if (person.DateTo != DateTo)
                {
                    var schedule = db.Schedules.Where(x => x.PersonId == person.PersonId && x.DateStart >= person.DateTo);
                    foreach (var item in schedule)
                    {
                        item.active          = false;
                        db.Entry(item).State = EntityState.Modified;
                    }
                    db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            ViewBag.DictDepartmentID = new SelectList(db.DictDepartments, "DictDepartmentID", "Name", person.DictDepartmentID);
            ViewBag.DictJobTitleID   = new SelectList(db.DictJobTitles, "DictJobTitleID", "Name", person.DictJobTitleID);
            ViewBag.DictSkillID      = new SelectList(db.DictSkills, "DictSkillID", "Name", person.DictSkillID);
            ViewBag.DictTeamID       = new SelectList(db.DictTeams, "DictTeamID", "Name", person.DictTeamID);
            return(View(person));
        }
Exemplo n.º 2
0
        // GET: Employees
        public async Task <IActionResult> Index(int?id, int?serviceID)
        {
            var viewModel = new EmployeeIndexData();

            viewModel.Employees = await _context.Employees
                                  .Include(i => i.OfficeAssignment)
                                  .Include(i => i.ServiceAssignments).ThenInclude(i => i.Service).ThenInclude(i => i.Schedules).ThenInclude(i => i.Patient)
                                  .Include(i => i.ServiceAssignments).ThenInclude(i => i.Service).ThenInclude(i => i.Department)
                                  .AsNoTracking().OrderBy(i => i.FirstName).ToListAsync();

            if (id != null)
            {
                ViewData["EmployeeID"] = id.Value;
                Employee employee = viewModel.Employees.Where(
                    i => i.ID == id.Value).Single();
                viewModel.Services = employee.ServiceAssignments.Select(s => s.Service);
            }

            if (serviceID != null)
            {
                ViewData["ServiceID"] = serviceID.Value;
                var selectedService = viewModel.Services.Where(x => x.ServiceID == serviceID).Single();
                await _context.Entry(selectedService).Collection(x => x.Schedules).LoadAsync();

                foreach (Schedule schedule in selectedService.Schedules)
                {
                    await _context.Entry(schedule).Reference(x => x.Patient).LoadAsync();
                }
                viewModel.Schedules = selectedService.Schedules;
            }

            return(View(viewModel));
        }
Exemplo n.º 3
0
        public void Update(Schedule schedule)
        {
            _context.Entry(schedule).State = EntityState.Unchanged;
            foreach (Appointment appointment in schedule.Appointments)
            {
                switch (appointment.State)
                {
                case TrackingState.Added:
                    //_context.Add(appointment);        // This would also work.
                    _context.Entry(appointment).State           = EntityState.Added;
                    _context.Entry(appointment.TimeRange).State = EntityState.Added;
                    break;

                case TrackingState.Modified:
                    //_context.Update(appointment);     // This would also work.
                    _context.Entry(appointment).State = EntityState.Modified;
                    break;

                case TrackingState.Deleted:
                    // _context.Remove(appointment);       // This would also work.
                    _context.Entry(appointment).State = EntityState.Deleted;
                    break;
                }
            }
            _context.SaveChanges();
        }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "ScheduleId,PersonId,DateStart,DateEnd,ScheduleStatus,ScheduleDesc,WorkplaceId,active")] Schedule schedule)
 {
     if (ModelState.IsValid)
     {
         db.Entry(schedule).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PersonId    = new SelectList(db.Persons, "PersonId", "FullName", schedule.PersonId);
     ViewBag.WorkplaceId = new SelectList(db.Workplaces, "WorkplaceId", "Name", schedule.WorkplaceId);
     return(View(schedule));
 }
Exemplo n.º 5
0
        public Schedule Save(Schedule schedule)
        {
            if (schedule.Id == 0)
            {
                _db.Schedules.Add(schedule);
            }
            else
            {
                _db.Entry(schedule).State = EntityState.Modified;
            }

            _db.SaveChanges();

            return(schedule);
        }
Exemplo n.º 6
0
 public ActionResult Edit(
     [Bind(Include = "schActive, schKey")]
     Schedule theSchRow)
 {
     try
     {
         if (ModelState.IsValid)
         {
             Schedule schItem = schcontext.Schedules.Find(theSchRow.schKey);
             if (schItem == null)
             {
                 return(HttpNotFound());
             }
             schItem.schActive = theSchRow.schActive;
             schcontext.Entry(schItem).State = EntityState.Modified;
             schcontext.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException /* dex */)
     {
         //Log the error (uncomment dex variable name after DataException and add a line here to write a log.
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(View(theSchRow));
 }
Exemplo n.º 7
0
        public bool DeletSchedule(Schedule schedule)
        {
            try
            {
                using (ScheduleContext = new ScheduleContext(database))
                {
                    var sche = schedule = ScheduleContext.Schedules.Where(
                        i => i.PoNumber == schedule.PoNumber &&
                        i.Model == schedule.Model &&
                        i.ModelName == schedule.ModelName &&
                        i.Article == schedule.Article &&
                        i.Quantity == schedule.Quantity &&
                        i.ProductionLine_Id == schedule.ProductionLine_Id).First();
                    if (sche == null)
                    {
                        return(false);
                    }

                    ScheduleContext.Entry(sche).State = EntityState.Deleted;
                    ScheduleContext.SaveChanges();
                    return(true);
                }
            }
            catch (Exception e)
            { return(false); }
        }
        public async Task <IActionResult> PutCustomer(long id, Customer customer)
        {
            if (id != customer.Id)
            {
                return(BadRequest());
            }

            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutAppointment(long id, string problemDetails, string statusName, string notes, string imageUrl)
        {
            var statusId    = _context.AppointmentStatuses.First(s => s.StatusName == statusName).Id;
            var appointment = _context.Appointments.First(e => e.Id == id);

            if (appointment == null)
            {
                return(BadRequest());
            }

            appointment.ProblemDetails      = problemDetails;
            appointment.AppointmentStatusId = statusId;
            appointment.Notes    = notes;
            appointment.ImageUrl = imageUrl;
            _context.Entry(appointment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AppointmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 10
0
        public async Task <IActionResult> PutScheduleEngineer(string id, ScheduleEngineer scheduleEngineer)
        {
            if (id != scheduleEngineer.Id)
            {
                return(BadRequest());
            }

            _context.Entry(scheduleEngineer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ScheduleEngineerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 11
0
        public async Task <ActionResult> Edit([Bind(Include = "Id, GroupName, CourseId, Students,SpecialityId")] Group group)
        {
            if (ModelState.IsValid)
            {
                context.Entry(group).State = EntityState.Modified;
                await context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(group));
        }
Exemplo n.º 12
0
        public async Task <ActionResult> Edit([Bind(Include = "AuditoryId,AuditoryName")] AuditorySet auditorySet)
        {
            if (ModelState.IsValid)
            {
                db.Entry(auditorySet).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(auditorySet));
        }
Exemplo n.º 13
0
        public async Task <ActionResult> Edit(LecturerSet lecturerSet)
        {
            if (ModelState.IsValid)
            {
                db.Entry(lecturerSet).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(lecturerSet));
        }
Exemplo n.º 14
0
        public async Task <ActionResult> Edit([Bind(Include = "PairId,PairNumber,PairStart,PairEnd")] PairSet pairSet)
        {
            if (ModelState.IsValid)
            {
                db.Entry(pairSet).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(pairSet));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name")] Speciality speciality)
        {
            if (ModelState.IsValid)
            {
                db.Entry(speciality).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(speciality));
        }
 public ActionResult Edit([Bind(Include = "DictTeamID,DictTeamForeignID,DictDepartmentID,Name")] DictTeam dictTeam)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dictTeam).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DictDepartmentID = new SelectList(db.DictDepartments, "DictDepartmentID", "Name", dictTeam.DictDepartmentID);
     return(View(dictTeam));
 }
Exemplo n.º 17
0
        public async Task <ActionResult> Edit([Bind(Include = "DisciplineId,TitleDiscipline")] DisciplineSet disciplineSet)
        {
            if (ModelState.IsValid)
            {
                db.Entry(disciplineSet).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(disciplineSet));
        }
Exemplo n.º 18
0
 public ActionResult Edit([Bind(Include = "Id,ProgramId,CourseId,CourseName,Topic,TimeAllocationHelperId,AmountOfTeachingHours")] CourseWithTimeAllocation courseWithTimeAllocation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(courseWithTimeAllocation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TimeAllocationHelperId = new SelectList(db.TimeOfCourse, "Id", "Id", courseWithTimeAllocation.TimeAllocationHelperId);
     return(View(courseWithTimeAllocation));
 }
Exemplo n.º 19
0
        public async Task <ActionResult> Edit([Bind(Include = "GroupId,GroupName,DepartmentName,MonitorOfTheTeam,MonitorTel,MonitorEmail")] GroupSet groupSet)
        {
            if (ModelState.IsValid)
            {
                db.Entry(groupSet).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(groupSet));
        }
Exemplo n.º 20
0
        public ActionResult Edit([Bind(Include = "DictDepartmentID,DictDepartmentForeignID,Name")] DictDepartment dictDepartment)
        {
            if (ModelState.IsValid)
            {
                db.Entry(dictDepartment).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dictDepartment));
        }
Exemplo n.º 21
0
 public bool UpdateScheuleClass(ScheduleClass _scheduleClass)
 {
     try
     {
         using (ScheduleContext = new ScheduleContext(database))
         {
             ScheduleContext.Entry(_scheduleClass).State = EntityState.Modified;
             ScheduleContext.SaveChanges();
             return(true);
         }
     }
     catch { return(false); }
 }
Exemplo n.º 22
0
 public bool UpdateScheuleProperties(UpdateSchProperty _updateSchProperty)
 {
     try
     {
         using (ScheduleContext = new ScheduleContext(database))
         {
             ScheduleContext.Entry(_updateSchProperty).State = EntityState.Modified;
             ScheduleContext.SaveChanges();
             return(true);
         }
     }
     catch { return(false); }
 }
Exemplo n.º 23
0
        public EventTimeData Save(EventTimeData eventTimeData)
        {
            if (eventTimeData.Id == 0)
            {
                _db.EventTimeData.Add(eventTimeData);
            }
            else
            {
                _db.Entry(eventTimeData).State = EntityState.Modified;
            }

            _db.SaveChanges();

            return(eventTimeData);
        }
Exemplo n.º 24
0
        public Event Save(Event ev)
        {
            if (ev.Id == 0)
            {
                _db.Events.Add(ev);
            }
            else
            {
                _db.Entry(ev).State = EntityState.Modified;
            }

            _db.SaveChanges();

            return(ev);
        }
Exemplo n.º 25
0
        public Reminder Save(Reminder reminder)
        {
            if (reminder.Id == 0)
            {
                _db.Reminders.Add(reminder);
            }
            else
            {
                _db.Entry(reminder).State = EntityState.Modified;
            }

            _db.SaveChanges();

            return(reminder);
        }
Exemplo n.º 26
0
        public async Task <ActionResult> Edit([Bind(Include = "ScheduleId,Date,DisciplineDisciplineId,LecturerLecturerId,GroupGroupId,AuditoryAuditoryId,PairPairId,Annotation,DaysOfWeek")] ScheduleMainSet scheduleMainSet)
        {
            if (ModelState.IsValid)
            {
                db.Entry(scheduleMainSet).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.AuditoryAuditoryId     = new SelectList(db.AuditorySet, "AuditoryId", "AuditoryName", scheduleMainSet.AuditoryAuditoryId);
            ViewBag.DisciplineDisciplineId = new SelectList(db.DisciplineSet, "DisciplineId", "TitleDiscipline", scheduleMainSet.DisciplineDisciplineId);
            ViewBag.GroupGroupId           = new SelectList(db.GroupSet, "GroupId", "GroupName", scheduleMainSet.GroupGroupId);
            ViewBag.LecturerLecturerId     = new SelectList(db.LecturerSet, "LecturerId", "LecturerFullName", scheduleMainSet.LecturerLecturerId);
            ViewBag.PairPairId             = new SelectList(db.PairSet, "PairId", "PairNumber", scheduleMainSet.PairPairId);
            return(View(scheduleMainSet));
        }
 public ActionResult Edit(int id, [Bind(Include = "Id,TeacherId,Teachers,Hours,Experience_months,Salary,Taxes,Bonus")] TeachersBookkeeping teacher)
 {
     try
     {
         if (ModelState.IsValid)
         {
             context.Entry(teacher).State = EntityState.Modified;
             context.SaveChanges();
             return(RedirectToAction("Index/" + teacher.Teachers.UniversityId));
         }
         return(View(teacher));
     }
     catch (Exception ex)
     {
         return(View(teacher));
     }
 }
 public ActionResult Edit(int id, Student student)
 {
     try
     {
         if (ModelState.IsValid)
         {
             context.Entry(student).State = EntityState.Modified;
             context.SaveChanges();
             return(Redirect("~/Students/Index/" + student.GroupId));
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Edit(int id, University university)
 {
     try
     {
         if (ModelState.IsValid)
         {
             context.Entry(university).State = EntityState.Modified;
             context.SaveChanges();
             return(RedirectToAction("Universities"));
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Edit([Bind(Include = "DictDaysOffId,DictDepartmentID,DateDayOff")] DictDaysOff dictDaysOff)
 {
     if (ModelState.IsValid)
     {
         try
         {
             db.Entry(dictDaysOff).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (RetryLimitExceededException /* dex */)
         {
             //Log the error (uncomment dex variable name and add a line here to write a log.)
             ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
         }
     }
     ViewBag.DictDepartmentID = new SelectList(db.DictDepartments, "DictDepartmentID", "Name", dictDaysOff.DictDepartmentID);
     return(View(dictDaysOff));
 }