private void btnClassSave_Click(object sender, RoutedEventArgs e)
        {
            if (FormMode == FormModes.View)
            {
                this.ActualParent.Close();
                return;
            }

            var parent = (ucClassListView)this.ParentContainer;

            ClassDetail.created_by = ClassDetail.updated_by = Utilities.UserSession.UserID;

            if (FormMode == FormModes.New)
            {
                _classid = ClassRepo.Insert(ClassDetail);
                parent.AddToClassList(ClassDetail);
            }
            else
            {
                ClassRepo.Update(ClassDetail);
                parent.Refreshlist();
            }
            ClassSubjectRepo.SaveSubjects(SelectedSubjectList, _classid, Utilities.UserSession.UserID);
            this.ActualParent.Close();
        }
Пример #2
0
        public IHttpActionResult Edit(int id, ClassDto classDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != classDto.ClassId)
            {
                return(Content(HttpStatusCode.NotFound, "Item does not exist"));
            }

            try
            {
                classRepo.Update(Mapper.Map <Class>(classDto));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClassExists(id))
                {
                    return(Content(HttpStatusCode.NotFound, "Item does not exist"));
                }
                else
                {
                    throw;
                }
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }