public ActionResult Edit(Guid id) { Producer producer = _producerService.Find(id); ProducerViewModel producerViewModel = Mapper.Map <ProducerViewModel>(producer); return(View("_EditProducer", producerViewModel)); }
protected void MergeProducerToMainDocument(ProducerViewModel producer, PropertyInfo[] properties) { foreach (var field in CorrespondingMergeFields) { MergeFieldDataMapper.BindCorrespondingField(field, producer, properties); } }
public async Task<IActionResult> Create( [Bind("Producer","Winery", "Brewery")] ProducerViewModel producerViewModel) { if(ModelState.IsValid) { var status = _context.Add(producerViewModel.Producer); if (producerViewModel.Winery != null){ producerViewModel.Winery.Producer = producerViewModel.Producer; _context.Add(producerViewModel.Winery); } if (producerViewModel.Brewery != null){ producerViewModel.Brewery.Producer = producerViewModel.Producer; _context.Add(producerViewModel.Brewery); } if (producerViewModel.Brewery == null && producerViewModel.Winery == null) throw new Exception(); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(producerViewModel); }
public ActionResult Edit(ProducerViewModel producerViewModel, HttpPostedFileBase image) { if (ModelState.IsValid) { Producer oldProducer = _producerService.Find(producerViewModel.Id); if (oldProducer == null) { return(HttpNotFound()); } Producer producer = Mapper.Map <Producer>(producerViewModel); if (image != null) { if (CheckImageUploadExtension.CheckImagePath(image.FileName) == true) { var path = Path.Combine(Server.MapPath("~/Images/Upload"), image.FileName); image.SaveAs(path); producer.Thumbnail = VariableUtils.UrlUpLoadImage + image.FileName; } } else { if (oldProducer.Thumbnail != null) { producer.Thumbnail = oldProducer.Thumbnail; } } _producerService.Update(producer, producer.Id); return(RedirectToAction("Index")); } return(View(producerViewModel)); }
public IActionResult Post([FromBody] ProducerViewModel producer) { try { if (ModelState.IsValid) { var newProducer = _mapper.Map <ProducerViewModel, Producer>(producer); if (!_repository.IsProducerExist(newProducer)) { var result = _repository.AddProducer(newProducer); return(Ok(_mapper.Map <Producer, ProducerViewModel>(result))); } else { return(BadRequest("Producer Already Exist")); } } else { return(BadRequest(ModelState)); } //return Ok(result); } catch (Exception ex) { _logger.LogError($"Failed to add producer to database: {ex}"); return(BadRequest("Failed to add producer to databse")); } }
public void OpenWindow(IEntity entity, WindowType windowsType, IBLC blc, IDialogService dialogService) { var guid = Guid.NewGuid().ToString(); Window window; switch (windowsType) { case WindowType.MotorbikeWindow: { window = new MotorbikeView(); var viewModel = new MotorbikeViewModel((IMotorbike)entity, guid, blc, dialogService); window.DataContext = viewModel; break; } case WindowType.ProducerWindow: { window = new ProducerView(); var viewModel = new ProducerViewModel((IProducer)entity, guid, blc, dialogService); window.DataContext = viewModel; break; } default: throw new ArgumentOutOfRangeException(nameof(windowsType), windowsType, null); } _windows.Add(guid, window); window.ShowDialog(); }
protected void MergeSiteOfExportInAnnex(ProducerViewModel siteOfExportProducer, PropertyInfo[] properties) { foreach (var mergeField in FindSiteOfExportMergeFields()) { MergeFieldDataMapper.BindCorrespondingField(mergeField, siteOfExportProducer, properties); } }
public ActionResult ProducerList() { List <Producer> pList = repository.Producers.ToList(); var model = new ProducerViewModel(); model.list = new SelectList(pList, "Id", "Name"); return(View(model)); }
public ActionResult Delete(Guid?id) { Producer producer = _producerService.Find(id); ProducerViewModel producerViewModel = Mapper.Map <ProducerViewModel>(producer); return(PartialView("_DeleteProducer", producerViewModel)); }
public JsonResult AddProducer(ProducerViewModel producer) { ExternalService service = new ExternalService(); ProducerDTO producerDTO = Mapper.Map <ProducerDTO>(producer); var result = service.AddProducer(producerDTO); return(Json(new { data = result, JsonRequestBehavior.AllowGet })); //return View(); }
protected void MergeProcessOfGenerationTextInAnnex(ProducerViewModel pvm, PropertyInfo[] proerties) { if (pvm.IsProcessAnnexAttached.GetValueOrDefault() || (pvm.ProcessOfGeneration.Length > ProducerViewModel.ProcessOfGenerationMaxTextLength())) { foreach (var mergeField in FindProcessOfGenerationTextMergeFields()) { MergeFieldDataMapper.BindCorrespondingField(mergeField, pvm, proerties); } } }
public async Task<ActionResult> Index(Guid id) { var producer = await mediator.SendAsync(new GetDraftData<Producer>(id)); var model = new ProducerViewModel(producer); var countries = await mediator.SendAsync(new GetCountries()); model.Address.Countries = countries; return View(model); }
public async Task <ActionResult> Index(Guid id) { var producer = await mediator.SendAsync(new GetDraftData <Producer>(id)); var model = new ProducerViewModel(producer); var countries = await mediator.SendAsync(new GetCountries()); model.Address.Countries = countries; return(View(model)); }
public virtual void GenerateAnnex(int annexNumber) { var properties = PropertyHelper.GetPropertiesForViewModel(typeof(ProducerViewModel)); MergeAnnexNumber(annexNumber); MergeProcessOfGenerationTextInAnnex(data[0], properties); TocText = "Annex " + annexNumber + " - Waste generators - producers"; if (data[0].IsProcessAnnexAttached.GetValueOrDefault()) { InstructionsText = "Process of generation - annex " + annexNumber; } //If there is only one producer but also an annex if (data.Count == 1) { MergeProducerToMainDocument(data[0].GetProducerViewModelShowingAnnexMessages(data.Count, data[0], annexNumber), properties); RemoveSiteOfGenerationTable(); ClearMultipleProducersTable(); } //If there are two producers the one that is the site of generation goes in the annex //and the other goes on the notification document in block 9 if (data.Count > 1) { //Merge site of generation to annex var indexOfSiteOfGeneration = data.Where(x => x.IsSiteOfGeneration).Select(data.IndexOf).Single(); MergeSiteOfExportInAnnex(data[indexOfSiteOfGeneration], properties); // Next remove the entry we have just merged so the multiple producers table doesn't contain this entry. data.RemoveAt(indexOfSiteOfGeneration); // If we only need the site of generation in the annex clear the remaining annex fields and exit at this point. if (data.Count < 2) { ClearMultipleProducersTable(); } // Merge the remaining producers into the multiple producers table and set the annex title. MergeMultipleProducersTable(properties); //If there is only one left put it on the form otherwise put them all in the annex MergeProducerToMainDocument(data[0].GetProducerViewModelShowingAnnexMessages(data.Count, data[0], annexNumber), properties); } //Clear the annex process of generation fields if they should not be displayed if (!(data[0].ProcessOfGeneration.Length > ProducerViewModel.ProcessOfGenerationMaxTextLength())) { ClearProcessOfGenerationTextFields(); } }
public IActionResult Update(ProducerViewModel vm) { var result = _mapper.Map <ProducerViewModel, Producer>(vm); if (ModelState.IsValid) { _producerService.Update(result); return(RedirectToAction("Index", "Producer")); } else { ModelState.AddModelError("", "Thêm mới thất bại"); } return(View("Create")); }
public HttpResponseMessage Update(HttpRequestMessage request, ProducerViewModel model) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { request.CreateErrorResponse(HttpStatusCode.BadGateway, ModelState); } else { try { string msgError = string.Empty; if (string.IsNullOrEmpty(model.ProducerName)) { throw new Exception("Vui lòng nhập tên nhà sản xuất!"); } Producer checkValidate = NSXService.GetAll() .Where(x => x.ProducerName.ToUpper().Equals(model.ProducerName.ToUpper()) && x.ProducerID != model.ProducerID).FirstOrDefault(); if (checkValidate != null) { msgError = string.Format("Nhà sản xuất {0} đã tồn tại. Vui lòng kiểm tra lại", model.ProducerName); throw new Exception(msgError); } Producer objResult = NSXService.GetSingleById(model.ProducerID); if (objResult != null) { objResult.ProducerName = model.ProducerName; NSXService.Update(objResult); NSXService.SaveChanges(); response = request.CreateResponse(HttpStatusCode.OK, "Cập nhật thành công!"); return response; } response = request.CreateResponse(HttpStatusCode.NotFound, "Xóa thất bại!"); return response; } catch (Exception ex) { response = request.CreateResponse(HttpStatusCode.NotFound, ex.Message); } } return response; })); }
public ActionResult Index(ProducerViewModel model) { if (model != null) { var producer = new Producer(); producer.Id = Guid.NewGuid(); producer.FirstName = model.FirstName; producer.LastName = model.LastName; producer.Link = model.Link; _context.Producers.Add(producer); _context.SaveChanges(); return(RedirectToAction("Index")); } return(HttpNotFound()); }
//Страница с Производителями public ActionResult PageProducer(string sortOrder, string currentFilter, string searchString, int page = 1) { int pageSize = globalPageSize;//Количество объектов на странице ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParam = String.IsNullOrEmpty(sortOrder) ? "Name desk" : ""; if (Request.HttpMethod == "GET") { searchString = currentFilter; } else { page = 1; } // SelectList producers = new SelectList(db.Producers, "ProducerId", "ProducerName"); IEnumerable <Producer> ProducersPerPages = db.Producers; int totalProducer = ProducersPerPages.Count();//Общее колчество производителей в БД ViewBag.CurrentFilter = searchString; if (!String.IsNullOrEmpty(searchString)) { ProducersPerPages = ProducersPerPages.Where(s => s.ProducerName.ToUpper().Contains(searchString.ToUpper())); } switch (sortOrder) { case "Name desk": ProducersPerPages = ProducersPerPages.OrderByDescending(x => x.ProducerName).Skip((page - 1) * pageSize).Take(pageSize).ToList(); break; default: ProducersPerPages = ProducersPerPages.OrderBy(x => x.ProducerName).Skip((page - 1) * pageSize).Take(pageSize).ToList(); break; } PageInfo pageInfo = new PageInfo { PageNumber = page, PageSize = pageSize, TotalItems = totalProducer }; ProducerViewModel pim = new ProducerViewModel { PageInfo = pageInfo, Producers = ProducersPerPages }; return(View(pim)); }
public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Producer producer = _producerService.Find(id); if (producer == null) { return(HttpNotFound()); } ProducerViewModel producerViewModel = Mapper.Map <ProducerViewModel>(producer); return(View(producerViewModel)); }
//[ActionName("CreateProducer")] public ActionResult CreateProducerPartialView(ProducerViewModel producerModel) { if (ModelState.IsValid) { Producer producer = new Producer(); producer.Name = producerModel.Name; producer.Sex = (byte)producerModel.Sex; producer.Bio = producerModel.Bio; producer.DOB = producerModel.DOB; db.Producers.Add(producer); db.SaveChanges(); return Content("Producer Added Successfully"); } ViewBag.Sex = new SelectList(MoviesController.GetGender(), "Value", "Text", producerModel.Sex); return PartialView(producerModel); }
public ActionResult Index(string producerId) { try { ProducerViewModel producer = _beatProvider.GetPageInfoByProducer(producerId); List <BeatViewModel> beats = _beatProvider.GetAllActiveBeatsByProducer(producerId); ViewDataViewModel data = new ViewDataViewModel() { Beats = beats, Producer = producer }; return(View(data)); } catch (Exception) { return(new HttpStatusCodeResult(400, "Invalid Url. Please try again from our home page, BeatSurge.com.")); } }
public HttpResponseMessage Create(HttpRequestMessage request, ProducerViewModel model) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { request.CreateErrorResponse(HttpStatusCode.BadGateway, ModelState); } else { try { string msgError = string.Empty; if (string.IsNullOrEmpty(model.ProducerName)) { throw new Exception("Vui lòng nhập tên nhà sản xuất!"); } Producer objDB = NSXService.GetAll() .Where(x => x.ProducerName.ToUpper().Equals(model.ProducerName.ToUpper())) .FirstOrDefault(); if (objDB != null) { msgError = string.Format("Nhà sản xuất {0} đã tồn tại. Vui lòng kiểm tra lại", model.ProducerName); throw new Exception(msgError); //return request.CreateResponse(HttpStatusCode.BadGateway, msgError); } Producer objNew = new Producer(); objNew.ProducerName = model.ProducerName; NSXService.Create(objNew); NSXService.SaveChanges(); response = request.CreateResponse(HttpStatusCode.OK, objNew); return response; } catch (Exception ex) { response = request.CreateResponse(HttpStatusCode.NotFound, ex.Message); } } return response; })); }
public async Task<ActionResult> Index(Guid id, ProducerViewModel model) { if (!ModelState.IsValid) { return View(model); } var producer = new Producer(id) { Address = model.Address.AsAddress(), AreMultiple = model.AreMultiple, BusinessName = model.BusinessName, Contact = model.Contact.AsContact() }; await mediator.SendAsync(new SetDraftData<Producer>(id, producer)); return RedirectToAction("Index", "Facility"); }
public ActionResult DisplayProducer(int producerId) { var producer = _producerRepository.GetById(producerId); if (producer == null) { return(HttpNotFound()); } var viewModel = new ProducerViewModel() { Bio = producer.Bio, DateOfBirth = producer.DateOfBirth, Name = producer.Name, Sex = producer.Sex, RowId = producer.RowId }; return(View(viewModel)); }
// GET: BuyPage public ActionResult Buy(string producerId, string orderId, int beatId) { ProducerViewModel producer = _beatProvider.GetPageInfoByProducer(producerId); BeatViewModel beat = _beatProvider.GetBeatByBeatAndProducer(beatId, producerId); TransactionViewModel data = new TransactionViewModel() { Beat = beat, Producer = producer, Order = orderId }; if ((orderId.ToLower() == "buy" || orderId.ToLower() == "lease") && beat.ActiveStatus == true) { return(View(data)); } else { return(new HttpStatusCodeResult(400, "Invalid Url. Please try again from our home page, BeatSurge.com.")); } }
public ActionResult Add() { CreateAlbumViewModel album = new CreateAlbumViewModel(); album.ProducerList = new List <ProducerViewModel>(); album.ArtistList = new List <ArtistViewModel>(); album.Producers = new SelectList(db.Producers.ToList(), "Id", "Name"); album.Artists = new SelectList(db.Artists.ToList(), "Id", "Name"); ProducerViewModel producer = new ProducerViewModel { Name = "", Studio = "", DateOfBirth = DateTime.Now }; ArtistViewModel artist = new ArtistViewModel { BirthDate = DateTime.Now, Email = "" }; album.ProducerList.Add(producer); album.ArtistList.Add(artist); return(View(album)); }
public async Task <ActionResult> Index(Guid id, ProducerViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var producer = new Producer(id) { Address = model.Address.AsAddress(), AreMultiple = model.AreMultiple, BusinessName = model.Business.Name, Contact = model.Contact.AsContact(), IsAddedToAddressBook = model.IsAddedToAddressBook }; await mediator.SendAsync(new SetDraftData <Producer>(id, producer)); return(RedirectToAction("Index", "Facility")); }
public ProducerViewModel GetPageInfoByProducer(string producerId) { try { string connectionString = HostingEnvironment.ApplicationPhysicalPath + String.Format("/Producers/{0}/PageInfo.txt", producerId); ProducerViewModel model = new ProducerViewModel(); using (StreamReader sr = new StreamReader(connectionString)) { string line = sr.ReadLine(); string[] values = line.Split(','); model.Title = values[0]; model.Subtitle = values[1]; model.PrimaryColor = values[2]; model.SecondaryColor = values[3]; model.TextColor = values[4]; } return(model); } catch { throw new Exception("Invalid Url. Please try again from our home page, BeatSurge.com."); } }
public ActionResult CreateEditProducer(ProducerViewModel viewModel) { if (ModelState.IsValid) { var producer = new Producer() { Bio = viewModel.Bio, DateOfBirth = viewModel.DateOfBirth, Name = viewModel.Name, Sex = viewModel.Sex }; _producerRepository.Insert(producer); _producerRepository.Save(); return(Json(new { success = true, producerId = producer.RowId })); } else { return(PartialView("_CreateEditProducer", viewModel)); } }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; PVM = new ProducerViewModel(); foreach (var task in BackgroundTaskRegistration.AllTasks) { if (task.Value.Name == TaskName) { taskRegistered = true; break; } } if (taskRegistered == false) { RegisterBackgroundTask(); } }
public ActionResult Create(ProducerViewModel producerViewModel, HttpPostedFileBase image) { if (ModelState.IsValid) { producerViewModel.Id = Guid.NewGuid(); Producer producer = Mapper.Map <Producer>(producerViewModel); if (image != null) { if (CheckImageUploadExtension.CheckImagePath(image.FileName) == true) { var path = Path.Combine(Server.MapPath("~/Images/Upload"), image.FileName); image.SaveAs(path); producer.Thumbnail = VariableUtils.UrlUpLoadImage + image.FileName; } } _producerService.Create(producer); return(RedirectToAction("Index")); } return(PartialView("_CreateProducer", producerViewModel)); }
public ActionResult CreateEditProducer(int?producerId) { if (producerId.HasValue) { var producer = _producerRepository.GetById(producerId); if (producer == null) { return(HttpNotFound()); } var viewModel = new ProducerViewModel() { Bio = producer.Bio, DateOfBirth = producer.DateOfBirth, Name = producer.Name, Sex = producer.Sex, RowId = producer.RowId }; return(PartialView("_CreateEditProducer", viewModel)); } else { return(PartialView("_CreateEditProducer")); } }