Пример #1
0
        public async Task <JsonResult> EditChildEductionInformation(ChildEditEducationViewModel model)
        {
            if (ModelState.IsValid)
            {
                var person = await _unitOfWork.People.GetOneAsync(x => x.Id == model.PersonId,
                                                                  include : p => p.Include(w => w.ChildInfo).Include(x => x.PersonToClasses));

                var classes = await _unitOfWork.Classes.GetAsync(x => x.OrganizationId == _organizationId && x.IsActive);


                person.Update(model);

                _unitOfWork.People.Update(person);
                var result = await _unitOfWork.SaveAsync();

                if (result.Succeeded)
                {
                    var personToClasses = person.PersonToClasses;

                    personToClasses.ForEach(x => x.IsActive = false);
                    _unitOfWork.PersonToClasses.UpdateRange(personToClasses);
                    foreach (var item in model.InClasses)
                    {
                        await _unitOfWork.PersonToClasses.Insert(PersonToClass.Create(person.Id, item, _userId));
                    }
                    var result2 = await _unitOfWork.SaveAsync();

                    return(Json(new JsonMessage {
                        Color = "#ff6849", Message = "Person saved", Header = "Success", Icon = "success", AdditionalData = model
                    }));
                }
            }
            return(Json(new JsonMessage {
                Color = "#ff6849", Message = "Error", Header = "Error", Icon = "error", AdditionalData = model
            }));
        }
Пример #2
0
 public void Update(ChildEditEducationViewModel model)
 {
     ChildInfo.DailySchedule  = model.DailySchedule?.Select(x => Convert.ToInt32(x)).ToList();
     ChildInfo.WeaklySchedule = model.WeaklySchedule?.Select(x => Convert.ToInt32(x)).ToList();
     ChildInfo.PipeLineType   = model.PipeLineType;
 }