public HttpResponseMessage GetAddData(HttpRequestMessage request) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; var model = new ManufacturerVM(); //templates PrepareTemplatesModel(model); //discounts PrepareDiscountModel(model, null, true); //ACL PrepareAclModel(model, null, false); //Stores PrepareStoresMappingModel(model, null, false); //default values model.PageSize = _catalogSettings.DefaultManufacturerPageSize; model.PageSizeOptions = _catalogSettings.DefaultManufacturerPageSizeOptions; model.Published = true; model.AllowCustomersToSelectPageSize = true; response = request.CreateResponse <ManufacturerVM>(HttpStatusCode.OK, model); return response; })); }
protected virtual void SaveStoreMappings(Manufacturer manufacturer, ManufacturerVM model) { manufacturer.LimitedToStores = model.SelectedStoreIds.Any(); var existingStoreMappings = _storeMappingService.GetStoreMappings(manufacturer); var allStores = _storeService.GetAllStores(); foreach (var store in allStores) { if (model.SelectedStoreIds.Contains(store.Id)) { //new store if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0) { _storeMappingService.InsertStoreMapping(manufacturer, store.Id); } } else { //remove store var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id); if (storeMappingToDelete != null) { _storeMappingService.DeleteStoreMapping(storeMappingToDelete); } } } }
protected virtual void UpdateLocales(Manufacturer manufacturer, ManufacturerVM model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(manufacturer, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(manufacturer, x => x.Description, localized.Description, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(manufacturer, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(manufacturer, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(manufacturer, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); //search engine name _urlRecordService.SaveSlug(manufacturer, localized.SeName, localized.LanguageId); } }
protected virtual void SaveManufacturerAcl(Manufacturer manufacturer, ManufacturerVM model) { manufacturer.SubjectToAcl = model.SelectedCustomerRoleIds.Any(); var existingAclRecords = _aclService.GetAclRecords(manufacturer); var allCustomerRoles = _customerService.GetAllCustomerRoles(true); foreach (var customerRole in allCustomerRoles) { if (model.SelectedCustomerRoleIds.Contains(customerRole.Id)) { //new role if (existingAclRecords.Count(acl => acl.CustomerRoleId == customerRole.Id) == 0) { _aclService.InsertAclRecord(manufacturer, customerRole.Id); } } else { //remove role var aclRecordToDelete = existingAclRecords.FirstOrDefault(acl => acl.CustomerRoleId == customerRole.Id); if (aclRecordToDelete != null) { _aclService.DeleteAclRecord(aclRecordToDelete); } } } }
public HomeViewModel() { ManufacturerVM = new ManufacturerVM(); WholesalerVM = new WholesalerVM(); PharmacyVM = new PharmacyVM(); PatientVM = new PatientVM(); }
private async void DeployButton_ClickAsync(object sender, RoutedEventArgs e) { var deployment = new DrugShipmentDeployment(); deployment.Name = (string.IsNullOrEmpty(tokenName.Text) || string.IsNullOrWhiteSpace(tokenName.Text)) ? ViewModel.Name : tokenName.Text; deployment.Symbol = (string.IsNullOrEmpty(tokenSymbol.Text) || string.IsNullOrWhiteSpace(tokenSymbol.Text)) ? ViewModel.Symbol : tokenSymbol.Text; ViewModel = DataContext as ManufacturerVM; await ViewModel.DeployCommand(deployment); }
/// <summary> /// 转换品牌视图和品牌实体 /// </summary> /// <param name="data"></param> /// <returns></returns> private ManufacturerInfo CovertVMtoEntity(ManufacturerVM data) { ManufacturerInfo msg = data.ConvertVM <ManufacturerVM, ManufacturerInfo>((v, t) => { t.ManufacturerDescription = new LanguageContent(v.ManufacturerDescription); t.ManufacturerNameLocal = new LanguageContent(v.ManufacturerNameLocal);; }); msg.SysNo = data.SysNo; msg.SupportInfo = data.SupportInfo.ConvertVM <ManufacturerSupportVM, ManufacturerSupportInfo>(); return(msg); }
private async void DispatchButton_ClickAsync(object sender, RoutedEventArgs e) { var fxn = new DispatchFunction(); fxn.SourceAddress = ViewModel.SetUp.Accounts.one.Address; fxn.SourceType = 0; fxn.DestinationAddress = (string.IsNullOrEmpty(_accountParam.Text) || string.IsNullOrWhiteSpace(_accountParam.Text)) ? ViewModel.SetUp.Accounts.two.Address : _accountParam.Text; fxn.DestinationType = (string.IsNullOrEmpty(_typeParam.Text) || string.IsNullOrWhiteSpace(_typeParam.Text)) ? Convert.ToByte(1) : Convert.ToByte(_typeParam.Text); fxn.TokenId = string.IsNullOrEmpty(tokenId.Text) || string.IsNullOrWhiteSpace(tokenId.Text) ? BigInteger.Parse(tokenId.Text) : new BigInteger(new Random().Next(10, 1000)); ViewModel = DataContext as ManufacturerVM; await ViewModel.DispatchCommand(fxn); await UpdateTracking(); }
public ManufacturerVM AddManufacturer(ManufacturerVM c) { DB.tblManufacturer Manufacturer = IMSDB.tblManufacturers.Add( new DB.tblManufacturer { ManufacturerName = c.ManufacturerName, Description = c.Description, ShortName = c.ShortName, IsActive = c.IsActive }); IMSDB.SaveChanges(); c.ManufacturerId = Manufacturer.ManufacturerId; return(c); }
public ManufacturerVM EditManufacturer(ManufacturerVM c) { DB.tblManufacturer Manufacturer = IMSDB.tblManufacturers.Find(c.ManufacturerId); if (Manufacturer != null) { Manufacturer.ManufacturerName = c.ManufacturerName; Manufacturer.Description = c.Description; Manufacturer.ShortName = c.ShortName; Manufacturer.IsActive = c.IsActive; IMSDB.Entry(Manufacturer).State = EntityState.Modified; IMSDB.SaveChanges(); } return(c); }
public ActionResult Edit(ManufacturerVM mManufacturerVm) { if (ModelState.IsValid) { var man = _svc.GetManufacturer(mManufacturerVm.ManufacturerId); if (TryUpdateModel(man)) { if (ExecuteRepositoryAction(() => { _svc.UpdateManufacturer(man); _svc.CommitChanges(); })) { return(ReturnJsonFormSuccess()); } } } return(PartialView(mManufacturerVm)); }
protected virtual void PrepareTemplatesModel(ManufacturerVM model) { if (model == null) { throw new ArgumentNullException("model"); } var templates = _manufacturerTemplateService.GetAllManufacturerTemplates(); foreach (var template in templates) { model.AvailableManufacturerTemplates.Add(new System.Web.Mvc.SelectListItem { Text = template.Name, Value = template.Id.ToString() }); } }
public ActionResult Create(ManufacturerVM obj) { try { // save Manufacturer obj.Manufacturer.Published = obj.isPubish; obj.Manufacturer.Deleted = obj.isDelete; obj.Manufacturer.CreatedOn = DateTime.Now; // save ManufacturerLocalized obj.ManufacturerLocalized.ManufacturerID = obj.Manufacturer.ManufacturerID; obj.Manufacturer.Fly_ManufacturerLocalized.Add(obj.ManufacturerLocalized); repository.Add(obj.Manufacturer); return(RedirectToAction("Index")); } catch (Exception e) { return(View(e.Message)); } }
protected virtual void PrepareDiscountModel(ManufacturerVM model, Manufacturer manufacturer, bool excludeProperties) { if (model == null) { throw new ArgumentNullException("model"); } if (!excludeProperties && manufacturer != null) { model.SelectedDiscountIds = manufacturer.AppliedDiscounts.Select(d => d.Id).ToList(); } foreach (var discount in _discountService.GetAllDiscounts(DiscountType.AssignedToManufacturers, showHidden: true)) { model.AvailableDiscounts.Add(new System.Web.Mvc.SelectListItem { Text = discount.Name, Value = discount.Id.ToString(), Selected = model.SelectedDiscountIds.Contains(discount.Id) }); } }
protected virtual void PrepareAclModel(ManufacturerVM model, Manufacturer manufacturer, bool excludeProperties) { if (model == null) { throw new ArgumentNullException("model"); } if (!excludeProperties && manufacturer != null) { model.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccess(manufacturer).ToList(); } var allRoles = _customerService.GetAllCustomerRoles(true); foreach (var role in allRoles) { model.AvailableCustomerRoles.Add(new System.Web.Mvc.SelectListItem { Text = role.Name, Value = role.Id.ToString(), Selected = model.SelectedCustomerRoleIds.Contains(role.Id) }); } }
private void BindPage(string brandSysNo) { if (!String.IsNullOrEmpty(brandSysNo)) { _facade = new ManufacturerFacade(); if (!int.TryParse(brandSysNo, out _sysNo)) { Window.MessageBox.Show("生产商编号无效.", MessageBoxType.Warning); } ; _facade.GetManufacturerBySysNo(_sysNo, (obj, args) => { if (args.FaultsHandle()) { return; } if (args.Result == null) { Window.MessageBox.Show("没有获得生产商信息.", MessageBoxType.Warning); return; } var vm = args.Result.Convert <ManufacturerInfo, ManufacturerVM>(); vm.SupportInfo = args.Result.SupportInfo.Convert <ManufacturerSupportInfo, ManufacturerSupportVM>(); DataContext = vm; }); } else { _sysNo = 0; var brand = new ManufacturerVM { SupportInfo = new ManufacturerSupportVM() }; DataContext = brand; cmbManufacturerStatusList.SelectedIndex = 0; } }
protected virtual void PrepareStoresMappingModel(ManufacturerVM model, Manufacturer manufacturer, bool excludeProperties) { if (model == null) { throw new ArgumentNullException("model"); } if (!excludeProperties && manufacturer != null) { model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(manufacturer).ToList(); } var allStores = _storeService.GetAllStores(); foreach (var store in allStores) { model.AvailableStores.Add(new System.Web.Mvc.SelectListItem { Text = store.Name, Value = store.Id.ToString(), Selected = model.SelectedStoreIds.Contains(store.Id) }); } }
public static Manufacturer ToEntity(this ManufacturerVM model) { return(model.MapTo <ManufacturerVM, Manufacturer>()); }
public HttpResponseMessage Add(HttpRequestMessage request, ManufacturerVM model, bool continueEditing = false) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (ModelState.IsValid) { var manufacturer = model.ToEntity(); manufacturer.CreatedOnUtc = DateTime.UtcNow; manufacturer.UpdatedOnUtc = DateTime.UtcNow; _manufacturerService.InsertManufacturer(manufacturer); //search engine name _urlRecordService.SaveSlug(manufacturer, model.SeName, 0); //locales UpdateLocales(manufacturer, model); //discounts var allDiscounts = _discountService.GetAllDiscounts(DiscountType.AssignedToManufacturers, showHidden: true); foreach (var discount in allDiscounts) { if (model.SelectedDiscountIds != null && model.SelectedDiscountIds.Contains(discount.Id)) { manufacturer.AppliedDiscounts.Add(discount); } } _manufacturerService.UpdateManufacturer(manufacturer); //update picture seo file name UpdatePictureSeoNames(manufacturer); //ACL (customer roles) SaveManufacturerAcl(manufacturer, model); //Stores SaveStoreMappings(manufacturer, model); //activity log _customerActivityService.InsertActivity("AddNewManufacturer", _localizationService.GetResource("ActivityLog.AddNewManufacturer"), manufacturer.Name); _baseService.Commit(); response = request.CreateResponse <Manufacturer>(HttpStatusCode.Created, manufacturer); if (continueEditing) { RedirectToRoute("GetManufacturerById", new { id = manufacturer.Id }); //// Generate a link to the update item and set the Location header in the response. //string uri = Url.Link("GetManufacturerById", new { id = manufacturer.Id }); //response.Headers.Location = new Uri(uri); } else { string uri = Url.Link("GetAll", null); response.Headers.Location = new Uri(uri); } } else { //If we got this far, something failed, redisplay form //templates PrepareTemplatesModel(model); //discounts PrepareDiscountModel(model, null, true); //ACL PrepareAclModel(model, null, true); //Stores PrepareStoresMappingModel(model, null, true); response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } return response; })); }
public ManufacturerVM EditManufacturer(ManufacturerVM c) { return(_ManufacturerBL.EditManufacturer(c)); }
public int DeleteManufacturer(ManufacturerVM c) { return(_ManufacturerBL.DeleteManufacturer(c.ManufacturerId)); }
public ManufacturerVM AddManufacturer(ManufacturerVM c) { return(_ManufacturerBL.AddManufacturer(c)); }
public HttpResponseMessage Update(HttpRequestMessage request, ManufacturerVM model, bool continueEditing = false) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = request.CreateResponse(HttpStatusCode.NotFound); var manufacturer = _manufacturerService.GetManufacturerById(model.Id); if (!ModelState.IsValid) { //If we got this far, something failed, redisplay form //templates PrepareTemplatesModel(model); //discounts PrepareDiscountModel(model, manufacturer, true); //ACL PrepareAclModel(model, manufacturer, true); //Stores PrepareStoresMappingModel(model, manufacturer, true); response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { if (manufacturer != null && !manufacturer.Deleted) { int prevPictureId = manufacturer.PictureId; manufacturer = model.ToEntity(manufacturer); manufacturer.UpdatedOnUtc = DateTime.UtcNow; _manufacturerService.UpdateManufacturer(manufacturer); _urlRecordService.SaveSlug(manufacturer, model.SeName, 0); //locales UpdateLocales(manufacturer, model); //discounts var allDiscounts = _discountService.GetAllDiscounts(DiscountType.AssignedToManufacturers, showHidden: true); foreach (var discount in allDiscounts) { if (model.SelectedDiscountIds != null && model.SelectedDiscountIds.Contains(discount.Id)) { //new discount if (manufacturer.AppliedDiscounts.Count(d => d.Id == discount.Id) == 0) { manufacturer.AppliedDiscounts.Add(discount); } } else { //remove discount if (manufacturer.AppliedDiscounts.Count(d => d.Id == discount.Id) > 0) { manufacturer.AppliedDiscounts.Remove(discount); } } } _manufacturerService.UpdateManufacturer(manufacturer); //delete an old picture (if deleted or updated) if (prevPictureId > 0 && prevPictureId != manufacturer.PictureId) { var prevPicture = _pictureService.GetPictureById(prevPictureId); if (prevPicture != null) { _pictureService.DeletePicture(prevPicture); } } //update picture seo file name UpdatePictureSeoNames(manufacturer); //ACL SaveManufacturerAcl(manufacturer, model); //Stores SaveStoreMappings(manufacturer, model); //activity log _customerActivityService.InsertActivity("EditManufacturer", _localizationService.GetResource("ActivityLog.EditManufacturer"), manufacturer.Name); _baseService.Commit(); response = request.CreateResponse <Manufacturer>(HttpStatusCode.OK, manufacturer); if (continueEditing) { // Generate a link to the update item and set the Location header in the response. string uri = Url.Link("GetManufacturerById", new { id = manufacturer.Id }); response.Headers.Location = new Uri(uri); } } } return response; })); }
public ActionResult _AddManufacturer() { var man = new ManufacturerVM(); return(PartialView("Edit", man)); }
public static Manufacturer ToEntity(this ManufacturerVM model, Manufacturer destination) { return(model.MapTo(destination)); }
/// <summary> /// 修改生產商 /// </summary> /// <param name="data"></param> /// <param name="callback"></param> public void UpdateManufacturer(ManufacturerVM data, EventHandler <RestClientEventArgs <ManufacturerInfo> > callback) { _restClient.Update(UPdateRelativeUrl, CovertVMtoEntity(data), callback); }