public ScoreModel Post(ScoreModel entity)
 {
     if (_scoretService.Add(entity) == ReturnResultEnum.EnumResult.success)
     {
         return(entity);
     }
     return(null);
 }
 public IActionResult Add(User user)
 {
     if (ModelState.IsValid)
     {
         _userService.Add(user);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Exemplo n.º 3
0
 public HttpResponseMessage AddSlide(HttpRequestMessage request, SlideViewModel modelVm)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         var model = new Slide();
         model.UpdateSlide(modelVm);
         _commonService.Add(model);
         _commonService.Save();
         response = request.CreateResponse(HttpStatusCode.OK, modelVm);
         return response;
     }));
 }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([FromBody] Asset oUser)
        {
            try
            {
                OrganizationModel og = new OrganizationModel();
                og = (OrganizationModel)oUser;
                await _organizationModel.Add(og);

                //await _assettService.Add(oUser);

                return(new OkObjectResult(oUser));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Internal server error" + ex.Message));
            }
        }
        public async Task <ActionResult> AddGearOil([FromBody] CommonAddDto gearOil)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                await _service.Add(gearOil);

                return(Ok());
            }
            catch (AddingException aex)
            {
                _log.Error(aex);
                return(StatusCode((int)HttpStatusCode.Forbidden, ErrorMessage.SAMENAME.ToString()));
            }
        }
Exemplo n.º 6
0
        public HttpResponseMessage Create(HttpRequestMessage request, SlideViewModel SlideVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    Slide slideDb = new Slide();

                    // Chuyen doi du lieu tu trang view toi du lieu cua model
                    slideDb.UpdateSlide(SlideVm);

                    if (!String.IsNullOrEmpty(SlideVm.Image))
                    {
                        var image = ConvertData.Base64ToImage(SlideVm.Image);

                        slideDb.Image = slideDb.ID + "_" + slideDb.Name + ".jpg";

                        string filePath = Path.Combine(HttpContext.Current.Server.MapPath("~/fileman/Uploads/")
                                                       + CommonConstants.PathProductCategory + "/" + slideDb.Image);

                        image.Save(filePath, ImageFormat.Jpeg);
                    }


                    // sau khi chuyen doi ta add du lieu
                    _commomService.Add(slideDb);
                    _commomService.Save();

                    //Sau khi luu xong chuyen doi lai wa du lieu cua view model de hien thi json
                    var responseData = Mapper.Map <Slide, SlideViewModel>(slideDb);
                    response = request.CreateResponse(HttpStatusCode.OK, responseData);
                }

                return response;
            }));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Add product
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public virtual ProductDataModel AddProduct(ProductDataModel model) => _commonService.Add(model);