Beispiel #1
0
        public virtual ActionResult AddOperation(string type, string styleId)
        {
            LogI("AddOperation, type=" + type + ", styleId=" + styleId);

            var model = new QuantityOperationViewModel()
            {
                Type    = StringHelper.TryGetEnum(type, QuantityOperationType.Exchange),
                StyleId = styleId
            };

            ViewBag.PartialViewName = PopupContentView;
            return(View("EditNew", model));
        }
Beispiel #2
0
        public virtual JsonResult Delete(long operationId)
        {
            LogI("Delete, operationId=" + operationId);

            QuantityOperationViewModel.Delete(Db,
                                              QuantityManager,
                                              Cache,
                                              operationId,
                                              Time.GetAppNowTime(),
                                              AccessManager.UserId);

            return(new JsonResult()
            {
                Data = MessageResult.Success(), JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Beispiel #3
0
        public virtual ActionResult GetAll([DataSourceRequest] DataSourceRequest request,
                                           string orderNumber,
                                           string styleString,
                                           long?styleItemId,
                                           long?userId,
                                           long?typeId,
                                           DateTime?dateFrom,
                                           DateTime?dateTo)
        {
            LogI("GetAll");
            var filter = new QuantityOperationFilterViewModel()
            {
                OrderNumber = orderNumber,
                StyleString = styleString,
                StyleItemId = styleItemId,
                DateFrom    = dateFrom,
                DateTo      = dateTo,
                UserId      = userId,
                Type        = (QuantityOperationType?)typeId
            };
            var items = QuantityOperationViewModel.GetAll(Db, filter);

            var sortField = Request.Params["sort[0][field]"];
            var sortDir   = Request.Params["sort[0][dir]"];

            if (!String.IsNullOrEmpty(sortField))
            {
                request.Sorts = new List <SortDescriptor>()
                {
                    new SortDescriptor()
                    {
                        Member        = sortField,
                        SortDirection = sortDir == "desc" ? ListSortDirection.Descending : ListSortDirection.Ascending
                    }
                };
            }
            ;

            /* new List<SortDescriptor>()
             * {
             * new SortDescriptor() { Member = "CreateDate", SortDirection = System.ComponentModel.ListSortDirection.Descending }
             * };*/
            var dataSource = items.ToDataSourceResult(request);

            return(JsonGet(dataSource));
        }
Beispiel #4
0
        public virtual ActionResult Submit(QuantityOperationViewModel model)
        {
            LogI("Submit, model=" + model);

            //Save
            if (ModelState.IsValid)
            {
                var errors = model.Validate(Db);
                if (!errors.Any())
                {
                    var quantityManager = new QuantityManager(LogService, Time);

                    var id = model.Add(Db,
                                       quantityManager,
                                       Cache,
                                       Time.GetAppNowTime(),
                                       AccessManager.UserId);
                }
                else
                {
                    foreach (var error in errors)
                    {
                        ModelState.AddModelError("", error.ErrorMessage);
                    }

                    return(PartialView(PopupContentView, model));
                }

                return(Json(new UpdateRowViewModel(model,
                                                   "quantityOperationGrid",
                                                   new[]
                {
                    "Type"
                },
                                                   false)));
            }

            return(View(PopupContentView, model));
        }