예제 #1
0
        public IActionResult Edit(SubjectEditModel subject)
        {
            SubjectBusiness subjectBusiness = new SubjectBusiness();
            var             result          = subjectBusiness.Edit(subject);

            return(Ok(result));
        }
예제 #2
0
        public async Task <ActionResult> Edit(SubjectEditModel model)
        {
            if (ModelState.IsValid)
            {
                using (var subjectManager = SubjectManager)
                {
                    var subject = await subjectManager.FindByIdAsync(model.SubjectId);

                    if (subject != null)
                    {
                        subject.SubjectName = model.SubjectName;

                        var result = await subjectManager.UpdateAsync(subject);

                        if (!result.Succeeded)
                        {
                            AddErrors(result);
                            return(View(model));
                        }
                    }
                }
            }
            else
            {
                return(View(model));
            }
            return(RedirectToAction("Index", "Subject"));
        }
예제 #3
0
 public long Edit(SubjectEditModel model)
 {
     using (MyDbContext ctx = new MyDbContext())
     {
         if (IsExist(model.Id, model.Name))
         {
             throw new ApplicationException("题目已经存在!");
         }
         BaseService <SubjectEntity> bs = new BaseService <SubjectEntity>(ctx);
         var data = bs.GetById(model.Id);
         if (data == null)
         {
             throw new ApplicationException("不存在id为" + model.Id + "的数据");
         }
         data.Name  = model.Name;
         data.ItemA = model.ItemA;
         data.ItemB = model.ItemB;
         data.ItemC = model.ItemC;
         data.ItemD = model.ItemD;
         data.ItemE = model.ItemE;
         data.ItemF = model.ItemF;
         ctx.SaveChanges();
         return(data.Id);
     }
 }
예제 #4
0
        public async Task Update(SubjectEditModel model)
        {
            Subject subject = repository.All().Where(x => x.Id == model.Id).FirstOrDefault();

            subject.Name = model.Name;
            repository.Update(subject);
        }
        public async Task <IActionResult> UpdateSubject(int id, [FromBody] SubjectEditModel subjectForUpdate)
        {
            var subject = await _quantumITAppService.UpdateSubjectAsync(id, subjectForUpdate);

            return(Ok(subject));

            throw new Exception($"updating subject {id} failed on save!");
        }
예제 #6
0
        public async Task <bool> UpdateSubjectAsync(int id, SubjectEditModel subjectForUpdate)
        {
            var subject = await _subjectRepository.GetByIdAsync(id);

            subject = _mapper.Map <SubjectEditModel, Subject>(subjectForUpdate, subject);

            return(await _subjectRepository.UpdateAsync(subject));
        }
        public async Task <IActionResult> AddSubject([FromBody] SubjectEditModel subjectForUpdate)
        {
            var subject = await _quantumITAppService.AddSubjectAsync(subjectForUpdate);

            return(Ok(subject));

            throw new Exception($"adding new subject failed!");
        }
        public async Task <ActionResult> Edit(SubjectEditModel Subject)
        {
            Subject.EditBy = _userSessionHelper.GetUserSession().UserName;
            string apiUrl = _appUrlHelper.GetApiUrl(ApiUrlPath.SUBJECT_EDIT);
            var    result = await HttpUtilities.PostAsyncApi <ReturnResult <SubjectEditModel> >(apiUrl, JsonConvert.SerializeObject(Subject));

            return(Json(result));
        }
예제 #9
0
        public async Task <SubjectModel> AddSubjectAsync(SubjectEditModel subjectForUpdate)
        {
            var subject = _mapper.Map <Subject>(subjectForUpdate);

            subject = await _subjectRepository.AddAsync(subject);

            return(_mapper.Map <SubjectModel>(subject));
        }
예제 #10
0
        public async Task <IActionResult> UpdateSubject(int id, [FromBody] SubjectEditModel subjectForUpdate)
        {
            var subject = await _quantumITAppService.UpdateSubjectAsync(id, subjectForUpdate);

            if (!subject)
            {
                return(BadRequest("Subject with this name already exists!"));
            }
            return(Ok(subject));
        }
        public async Task <IActionResult> Edit(SubjectEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await subjectService.Update(model);

            return(RedirectToAction("Index", "Home"));
        }
예제 #12
0
 public override void FuncPreInitEditView(object id, ref Subject EditItem, ref SubjectEditModel model)
 {
     if (EditItem == null)
     {
         //get the item by id
         EditItem = new SubjectModel <Subject>().Get(id);
     }
     if (EditItem != null)
     {
         model          = new SubjectEditModel();
         model.EditItem = EditItem;
     }
 }
예제 #13
0
        public async Task <ActionResult> Edit(string id)
        {
            var subject = await SubjectManager.FindByIdAsync(id);

            if (subject != null)
            {
                var model = new SubjectEditModel()
                {
                    SubjectId = subject.Id, SubjectName = subject.SubjectName
                };
                return(View(model));
            }
            return(RedirectToAction("Index", "Subject"));
        }
예제 #14
0
        public ReturnResult <Subject> Edit(SubjectEditModel mouse)
        {
            DbProvider dbProvider = new DbProvider();
            string     outCode    = String.Empty;
            string     outMessage = String.Empty;
            StoredProcedureConfigs <Subject> storedProcedureConfigs = new StoredProcedureConfigs <Subject>();

            dbProvider.SetQuery(storedProcedureConfigs._UPDATE_SINGLE_STORED_PROCEDURE, CommandType.StoredProcedure)
            .SetParameter("Id", SqlDbType.NVarChar, mouse.Pk_id, 100, ParameterDirection.Input)
            .SetParameter("Name", SqlDbType.NVarChar, mouse.Name, 100, ParameterDirection.Input)
            .SetParameter("Status", SqlDbType.Int, mouse.Status, ParameterDirection.Input)
            .SetParameter("EditBy", SqlDbType.NVarChar, mouse.EditBy, ParameterDirection.Input)
            .SetParameter("ERROR_CODE", SqlDbType.NVarChar, DBNull.Value, 100, ParameterDirection.Output)
            .SetParameter("ERROR_MESSAGE", SqlDbType.NVarChar, DBNull.Value, 400, ParameterDirection.Output)
            .ExcuteNonQuery()
            .Complete();
            dbProvider.GetOutValue("ERROR_CODE", out outCode)
            .GetOutValue("ERROR_MESSAGE", out outMessage);
            return(new ReturnResult <Subject>()
            {
                ErrorCode = outCode,
                ErrorMessage = outMessage,
            });
        }
예제 #15
0
 public ReturnResult <Subject> Edit(SubjectEditModel mouse)
 {
     return(SubjectDAL.Edit(mouse));
 }
        public async Task <ActionResult <SubjectViewModel> > UpdateSubject(string code, [FromBody] SubjectEditModel editModel)
        {
            Subject subject = await dbContext.Subjects.FindAsync(code);

            if (subject is null)
            {
                return(NotFound($"Asignatura no encontrada: {code}"));
            }

            _mapper.Map(editModel, subject);
            dbContext.Subjects.Update(subject);
            await dbContext.SaveChangesAsync();

            return(_mapper.Map <SubjectViewModel>(subject));
        }
        public IActionResult Edit(int id)
        {
            SubjectEditModel subject = subjectService.GetById <SubjectEditModel>(id);

            return(View(subject));
        }