Ejemplo n.º 1
0
        public ActionResult SaveData(ProjectTypeChangeViewModel projecttypes)
        {
            if (projecttypes.updated != null)
            {
                foreach (var updated in projecttypes.updated)
                {
                    _projectTypeService.Update(updated);
                }
            }
            if (projecttypes.deleted != null)
            {
                foreach (var deleted in projecttypes.deleted)
                {
                    _projectTypeService.Delete(deleted);
                }
            }
            if (projecttypes.inserted != null)
            {
                foreach (var inserted in projecttypes.inserted)
                {
                    _projectTypeService.Insert(inserted);
                }
            }
            _unitOfWork.SaveChanges();

            return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public IActionResult Update(int id, ProjectTypesModel updateModel)
        {
            var projectTypesFromRepo = _services.GetByID(id);

            _mapper.Map(updateModel, projectTypesFromRepo);
            _services.Update(projectTypesFromRepo);
            _services.SaveChange();
            return(Ok(updateModel));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(ProjectType projectType)
        {
            if (ModelState.IsValid)
            {
                _projectTypeService.Update(projectType);
                return(RedirectToAction("Index"));
            }

            SetViewBag(projectType);
            return(View(projectType));
        }
Ejemplo n.º 4
0
 public IHttpActionResult PutProjectType(ProjectType projectType)
 {
     //var projectTypeFromDb = projectTypeService.Get(projectType.ProjectTypeId);
     if (projectType != null)
     {
         var returnData = projectTypeService.Update(projectType);
         return(Ok(returnData));
     }
     else
     {
         return(NotFound());
     }
 }
        public async Task <IActionResult> PutProjectType([FromBody] ProjectType projectType)
        {
            if (projectType == null)
            {
                throw new ArgumentException($"{nameof(projectType)} can not be null");
            }

            User user = await _userManager.FindByNameAsync(User.Identity.Name);

            Guid userId = user.Id;
            await _service.Update(projectType, userId);

            return(Ok());
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> PutProjectType([FromBody] ProjectTypeViewModel projectTypeModel)
        {
            if (projectTypeModel == null)
            {
                throw new ArgumentException($"{nameof(projectTypeModel)} can not be null");
            }

            var mapper = new MapperConfiguration(cfg => cfg.CreateMap <ProjectTypeViewModel, ProjectTypeDto>())
                         .CreateMapper();
            var projectTypeDto = mapper.Map <ProjectTypeViewModel, ProjectTypeDto>(projectTypeModel);

            await _service.Update(projectTypeDto);

            return(Ok());
        }