Пример #1
0
        public virtual ActionResult Submit(ItemEditViewModel model)
        {
            LogI("Submit, model=" + model);

            model.PrepareData();

            //Save
            if (ModelState.IsValid)
            {
                IList <MessageString> messages;

                if (model.IsValid(Db, out messages))
                {
                    model.Save(Db,
                               Cache,
                               BarcodeService,
                               ActionService,
                               ItemHistoryService,
                               Time.GetAppNowTime(),
                               AccessManager.UserId);

                    return(Json(new UpdateRowViewModel(model,
                                                       "Products",
                                                       null,
                                                       false)));
                }
                else
                {
                    messages.ForEach(m => ModelState.AddModelError("model", m.Message));
                }
            }

            return(PartialView(PopupContentView, model));
        }
Пример #2
0
        public virtual ActionResult Validate(ItemEditViewModel model)
        {
            LogI("Validate, model=" + model);
            model.PrepareData();
            var messages = model.ValidateAsync(Db, LogService, Time.GetAppNowTime());

            foreach (var message in messages)
            {
                LogI("Validate, message=" + message.Message);
            }
            return(JsonGet(new ValueResult <IList <MessageString> >(true, "", messages)));
        }