示例#1
0
        public async Task EditAsync(ItemEditModel model)
        {
            var item = await _repository.GetAsync(model.Id);

            ItemFactory.Create(model, item, _userId);
            _repository.Edit(item);
            await _unitOfWork.SaveChangesAsync();
        }
        public ActionResult Edit(string code)
        {
            Item          item   = itemService.GetItemByCode(code);
            ItemEditModel itemEM = Mapper.Map <Item, ItemEditModel>(item);

            itemEM.CategoryList = GetSelectList(item);
            return(View(itemEM));
        }
示例#3
0
        public IActionResult Create()
        {
            ItemEditModel model = new ItemEditModel();

            model.Code = @"function main(arg)
{
    var htmlView = new HtmlView('<div>hello!</div>'); 
	return [htmlView];
}
main(arg);";
            return(View("Edit", model));
        }
示例#4
0
 public static void Create(ItemEditModel model, Item entity, string userId)
 {
     entity.Name          = model.Name;
     entity.Rate          = model.Rate;
     entity.Description   = model.Description;
     entity.IsTaxable     = model.IsTaxable?.Equals("1") ?? false;
     entity.SalesTaxId    = entity.IsTaxable ? model.SalesTaxId : null;
     entity.UpdatedBy     = userId ?? "0";
     entity.UpdatedOn     = Utility.GetDateTime();
     entity.isForSell     = model.isForSell?.Equals("1") ?? false;
     entity.BankAccountId = model.BankAccountId;
 }
示例#5
0
 public Item(ItemEditModel model)
 {
     this.Id     = model.Id;
     this.UserId = model.UserId;
     this.Price  = model.Price;
     //this.Quantity = model.Quantity;
     this.Description = model.Description;
     this.CanDelivery = model.CanDelivery;
     this.QQ          = model.QQ;
     this.Phone       = model.Phone;
     this.WeChat      = model.WeChat;
     this.CatalogId   = model.CatalogId;
 }
 public async Task <IActionResult> Edit([FromBody] ItemEditModel model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState.GetErrorList()));
     }
     try
     {
         await _manager.EditAsync(model);
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
     return(Ok());
 }
示例#7
0
 public ActionResult Edit(ItemEditModel model)
 {
     try
     {
         var item       = db.Items.Find(model.Id);
         var updateItem = new Item(model);
         updateItem.PostDate = item.PostDate;
         updateItem.OnSell   = item.OnSell;
         db.Entry(item).CurrentValues.SetValues(updateItem);
         db.SaveChanges();
     }
     catch (Exception e)
     {
         var s = e;
     }
     return(RedirectToAction("Detail", new { id = model.Id }));
 }
        public ActionResult Edit(ItemEditModel itemEM)
        {
            Item item = itemService.GetItemByCode(itemEM.Code);

            if (string.IsNullOrWhiteSpace(itemEM.CategoryId))
            {
                item.CategoryId = null;
            }
            else
            {
                item.CategoryId = Guid.Parse(itemEM.CategoryId);
            }
            item.Name  = itemEM.Name;
            item.Price = itemEM.Price;
            itemService.EditItem(item);

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> OItem(ItemEditModel model)
        {
            if (ModelState.IsValid)
            {
                //[0] vitemid, [1] oqty, [2] sid, [3] favorite,stock,core
                ICollection <string> selectedIds = new List <string>();
                selectedIds.Add(model.VItemID.ToString() + "-" + model.Quntity.ToString() + "-" + model.SeletedSid + "-" + model.Form + "-" + (string.IsNullOrEmpty(model.OFor) ? "" : model.OFor) + "-" + (string.IsNullOrEmpty(model.ONote) ? "" : model.ONote));

                await ProcessOrderSelected(selectedIds);

                SuccessNotification("The item has been added to the order.");

                return(RedirectToAction("OItem", "SelectItems",
                                        new { VitemID = model.VItemID, f = model.Form }));
            }

            return(View(model));
        }
示例#10
0
        public async Task <IActionResult> Run(
            [FromRoute] int?id,
            ItemEditModel editModel,
            ItemSettingsModel settings
            )
        {
            this.ModelState.Clear();

            if (id > 0)
            {
                Item item = await _domainContext.Items.Get(id.Value) ?? new Item();

                editModel = new ItemEditModelAssembler().ToModel(item);
            }

            ItemRunModel model = new ItemRunModel();

            model.EditModel = editModel;
            try
            {
                model.RunResult = await _jsService.Run(editModel.Code);

                if (model.RunResult.Exception != null)
                {
                    this.ModelState.AddModelError("", "Error, Line " + model.RunResult.LastExecutedLine + " :" + model.RunResult.Exception.Message);
                }

                foreach (var error in model.RunResult.Errors)
                {
                    this.ModelState.AddModelError("", error.ToJsonOrString());
                }
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError("", ex.Message);
            }

            if (settings.RenderAs == "subView")
            {
                return(PartialView("_Run", model));
            }
            return(View(model));
        }
示例#11
0
        public IActionResult EditItem(ItemEditModel model)
        {
            ItemModel updateItem = _itemData.Get(model.Id);
            string    _user      = User.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;

            if (ModelState.IsValid && _user == updateItem.Owner)
            {
                updateItem.Title       = model.Title;
                updateItem.Description = model.Description;
                updateItem.TopPrice    = model.TopPrice;
                updateItem.LowPrice    = model.LowPrice;
                updateItem.EndTime     = model.EndTime;
                updateItem.Active      = model.Active;
                _itemData.Update(updateItem);

                return(RedirectToAction(nameof(ViewItem), new { id = model.Id }));
            }
            else
            {
                return(View());
            }
        }
示例#12
0
        public async Task <IActionResult> Edit(int?id, ItemEditModel model)
        {
            if (model == null || ModelState.IsValid == false)
            {
                return(View("Edit", model));
            }

            var duplicateItem = await _domainContext.Items.GetByName(model.Name);

            if (duplicateItem != null && duplicateItem.Id != model.Id)
            {
                ModelState.AddModelError("Name", string.Format("Item with the name '{0}' already exists.", model.Name));
                return(View("Edit", model));
            }

            Item item = await _domainContext.Items.Get(id.GetValueOrDefault(0)) ?? new Item();

            new ItemEditModelAssembler().ApplayModel(item, model);
            _domainContext.Items.Save(item);
            await _domainContext.SaveAsync();

            return(View("Edit", new ItemEditModelAssembler().ToModel(item)));
        }
示例#13
0
        public IActionResult Create(ItemEditModel model)
        {
            if (ModelState.IsValid)
            {
                string _user   = User.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value;
                var    newItem = new ItemModel();
                newItem.Title       = model.Title;
                newItem.Description = model.Description;
                newItem.TopPrice    = model.TopPrice;
                newItem.LowPrice    = model.LowPrice;
                newItem.EndTime     = model.EndTime;
                newItem.StartDate   = DateTime.Now;
                newItem.Active      = true;
                newItem.Owner       = _user;
                _itemData.Add(newItem);

                return(RedirectToAction(nameof(ViewItem), new { id = newItem.Id }));
            }
            else
            {
                return(View());
            }
        }
        public async Task <bool> UpdateItem(ItemEditModel model)
        {
            var item = await _itemRepository.Table.Where(i => i.VitemId == model.VItemID).FirstOrDefaultAsync();

            item.MinQty = model.Quntity;
            item.MaxQty = model.Quntity;

            //item.MaxQty = model.Quntity;
            //item.SellingPrice = model.UnitPrice;

            if (string.IsNullOrEmpty(item.Gl))
            {
                item.Gl = model.GL;
            }

            var result = await _itemRepository.UpdateAsync(item);

            var vendor = await _vendorRepository.Table.Where(v => v.VendorId == item.VendorId).FirstOrDefaultAsync();

            vendor.Note = model.VNote;
            await _vendorRepository.UpdateAsync(vendor);

            return(true);
        }