public ActionResult UpdateSubGrid(MCustomerPrice viewModel, FormCollection formCollection, string itemId) { try { MCustomerPrice cp = _mCustomerPriceRepository.Get(viewModel.Id); cp.CustomerId = viewModel.CustomerId; cp.ItemId = _mitemRepository.Get(itemId); cp.Price = decimal.Parse(formCollection["Price"].Replace(",", "")); //Helper.CommonHelper.ConvertToDecimal(formCollection["Price"]); cp.ModifiedDate = DateTime.Now; cp.ModifiedBy = User.Identity.Name; cp.DataStatus = EnumDataStatus.Updated.ToString(); _mCustomerPriceRepository.Save(cp); _mCustomerPriceRepository.DbContext.CommitChanges(); } catch (Exception e) { _mCustomerPriceRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("Data Harga Konsumen berhasil disimpan")); }
private string GetCustomerPrice(MItem item, string customerId) { if (!string.IsNullOrEmpty(customerId)) { MCustomerPrice cp = _mCustomerPriceRepository.GetByItemCustomer(item.Id, customerId); if (cp != null) { return(cp.Price.HasValue ? cp.Price.Value.ToString(Helper.CommonHelper.NumberFormat) : "0"); } } return(item.ItemUoms.Count > 0 ? item.ItemUoms[0].ItemUomSalePrice.HasValue ? item.ItemUoms[0].ItemUomSalePrice.Value.ToString(Helper.CommonHelper.NumberFormat) : "0" : "0"); }
public ActionResult DeleteSubGrid(MCustomerPrice viewModel, FormCollection formCollection, string itemId) { try { MCustomerPrice cp = _mCustomerPriceRepository.Get(viewModel.Id); _mCustomerPriceRepository.Delete(cp); _mCustomerPriceRepository.DbContext.CommitChanges(); } catch (Exception e) { _mCustomerPriceRepository.DbContext.RollbackTransaction(); return(Content(e.GetBaseException().Message)); } return(Content("Data Harga Konsumen berhasil dihapus.")); }