Exemplo n.º 1
0
        public HttpResponseMessage PutSettings(SettingDisplay setting)
        {
            var response = Request.CreateResponse(HttpStatusCode.OK);

            try
            {
                IEnumerable <IStoreSetting> merchSetting = setting.ToStoreSetting(_storeSettingService.GetAll());
                foreach (var s in merchSetting)
                {
                    _storeSettingService.Save(s);
                }
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound, String.Format("{0}", ex.Message));
            }

            return(response);
        }
        public ActionResult DoUpsert(StoreUpModel model)
        {
            try
            {
                if (ModelState.IsValid == false)
                {
                    return(Json(new ResponseMessageModel
                    {
                        HasError = true,
                        Title = ResShared.TITLE_REGISTER_FAILED,
                        Message = ResShared.ERROR_INVALID_MODEL
                    }));
                }

                using (var service = new StoreSettingService())
                {
                    var response = service.ValidateModel(model);

                    if (response.HasError)
                    {
                        response.Title = ResShared.TITLE_REGISTER_FAILED;
                        return(Json(response));
                    }

                    model.UserInsUpId = User.Identity.GetUserId();
                    response          = service.Save(model);

                    if (response.HasError)
                    {
                        response.Title = ResShared.TITLE_REGISTER_FAILED;
                    }

                    return(Json(response));
                }
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
                return(Json(new ResponseMessageModel
                {
                    HasError = true,
                    Title = ResShared.TITLE_REGISTER_FAILED,
                    Message = ResShared.ERROR_UNKOWN
                }));
            }
        }