private void ProducerUpDown(ProducerModel e, dbEntities cnn, string routeKey) { var sectionName = string.Empty; using (var dbContextTransaction = cnn.Database.BeginTransaction()) { try { sectionName = "ProducerUpDown"; var spParams = "EXECUTE PROCEDURE BETDATA_ALIVE("; spParams += SourceId + ","; spParams += e.Id + ","; spParams += "'" + e.Description + "',"; spParams += (e.IsAvailable ? 1 : 0) + ","; spParams += (e.IsDisabled ? 1 : 0) + ","; spParams += (e.IsProducerDown ? 1 : 0) + ")"; cnn.Database.ExecuteSqlCommand(spParams.Trim()); dbContextTransaction.Commit(); SerilogHelper.Information(string.Format("ProducerUpDown ID:{0} Description:{1} IsAvailable:{2} IsDisabled:{3} IsProducerDown:{4}", e.Id, e.Description, e.IsAvailable, e.IsDisabled, e.IsProducerDown)); SerilogHelper.Information(string.Format("{0}", routeKey)); } catch (Exception ex) { dbContextTransaction.Rollback(); SerilogHelper.Exception(string.Format("Unknown exception in {0}", sectionName), ex); } } }
public async Task <IActionResult> Edit(int id, [Bind("IdPro,Name,Description,Date")] ProducerModel producerModel) { if (id != producerModel.IdPro) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(producerModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProducerModelExists(producerModel.IdPro)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(producerModel)); }
public IObjectIdentifier Save(ProducerModel input) { var producer = input.IsNew ? new Producer() : _repo.GetOrThrow <Producer>(input.Id); producer.Name = input.Name; _repo.Save(producer); _repo.Commit(); return(new ObjectIdentifier(producer.Name)); }
public async Task <IActionResult> Create([Bind("IdPro,Name,Description,Date")] ProducerModel producerModel) { if (ModelState.IsValid) { _context.Add(producerModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(producerModel)); }
public void SetUpSuite() { TestLogger.Setup(); GlobalOptions = new GlobalOptionsFactory().Load(); var testConnectionFactory = new ConnectionFactory { HostName = GlobalOptions.RabbitOptions.RabbitMqHostName, Port = GlobalOptions.RabbitOptions.RabbitMqHostPort, VirtualHost = GlobalOptions.RabbitOptions.RabbitMqVirtualHost, UserName = GlobalOptions.RabbitOptions.RabbitMqUserName, Password = GlobalOptions.RabbitOptions.RabbitMqPassword }; _testConnection = testConnectionFactory.CreateConnection("TestConnection"); TestModel = _testConnection.CreateModel(); TestModel.ConfirmSelect(); IBasicProperties props = TestModel.CreateBasicProperties(); props.ContentEncoding = "UTF-8"; props.ContentType = "application/json"; props.Persistent = true; TestModel.ExchangeDeclare(TestDlExchangeName, "topic", true); TestModel.QueueDeclare(TestDlQueueName, true, false, false); TestModel.QueueBind(TestDlQueueName, TestDlExchangeName, RabbitMqAdapter.RabbitMqRoutingKey_MatchAnything); var queueProps = new Dictionary <string, object> { { "x-dead-letter-exchange", TestDlExchangeName } }; TestModel.ExchangeDeclare(RejectExchangeName, "direct", true); TestModel.QueueDeclare(RejectQueueName, true, false, false, queueProps); TestModel.QueueBind(RejectQueueName, RejectExchangeName, TestRoutingKey); TestModel.ExchangeDeclare(GlobalOptions.RabbitOptions.RabbitMqControlExchangeName, "topic", true); TestModel.ExchangeDeclare(GlobalOptions.RabbitOptions.FatalLoggingExchange, "direct", true); TestProducer = new ProducerModel(RejectExchangeName, TestModel, props); _messageRejectorOptions = new ConsumerOptions { QueueName = RejectQueueName, QoSPrefetchCount = 1, AutoAck = false }; PurgeQueues(); _testAdapter = new RabbitMqAdapter(GlobalOptions.RabbitOptions.CreateConnectionFactory(), "TestHost"); }
public ActionResult EditProducer(long?id) { ProducerModel model = new ProducerModel(); try { model.GetProducer(model, (long)id); } catch { } return(View(model)); }
public ActionResult DeleteProducer(long id) { ProducerModel model = new ProducerModel(); try { model.DeleteProducerByProducerId(id); } catch { } return(RedirectToAction("ProducerList", new { sortingOrder = "FirstName", filterValue = "" })); }
public bool AddNewProducer(ProducerModel proinput) { Producer _producer = new Producer(); _producer.ProducerName = proinput.ProducerName; _producer.DateOfBirth = proinput.DOB; _producer.Bio = proinput.Bio; _producer.Gender = Convert.ToBoolean(proinput.Gender); Db.Producers.InsertOnSubmit(_producer); Db.SubmitChanges(); return(true); }
public ActionResult CreateProducer(ProducerModel model) { try { long producerId = model.AddProducer(model); } catch (Exception ex) { } return(RedirectToAction("ProducerList", new { sortingOrder = "FirstName", filterValue = "" })); }
public static int CreateProducer(string producer_name) { ProducerModel data = new ProducerModel { Producer_name = producer_name }; string sql = @"insert into dbo.Producer_Details(Producer_name) values (@Producer_name);"; return(SqlDataAccess.SaveData <ProducerModel>(sql, data)); }
//Detail public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProducerModel ProducerModel = _ProducerRep.GetProducerById(id); if (ProducerModel == null) { return(HttpNotFound()); } return(View(ProducerModel)); }
public ActionResult Edit(ProducerModel input) { try { var saved = _producerFacade.Save(input); AddSaveMessage(saved); return(RedirectToAction("List")); } catch (Exception ex) { AddError(ex); return(View(input)); } }
public void ConvertProducerModelToProducerEntity_CheckDefaultValues() { // Arrange ProducerModel producer = new ProducerModel() { Name = "SomeName", URL = "SomeURL" }; // Act var producerEntity = producer.ConvertToProducerEntity(); // Assert Assert.True(producerEntity.GetType() == typeof(DataAccess.Entities.Producer)); Assert.Equal(0, producerEntity.Id); Assert.Null(producerEntity.Devices); }
public async Task <OperationResult> Create(ProducerModel producerModel) { var producer = new Producer { Name = producerModel.Name, Description = producerModel.Description, ForeignId = producerModel.ForeignId, Address = producerModel.Address, City = producerModel.City, ZipCode = producerModel.ZipCode, Phone = producerModel.Phone, ContactPerson = producerModel.ContactPerson }; await producer.Create(_dbContext); return(new OperationResult(true)); }
public ProducerModel ToDataModel() { ProducerModel model = new ProducerModel() { Name = Name, Surname = Surname, BirthDate = BirthDate }; MyCollection <string> names = new MyCollection <string>(); foreach (var film in films) { names.Add(film.Name); } model.Films = names.ToArray(); return(model); }
public void CreateProjectModel() { // Arrange string Name = "FESTO"; string URL = "https://festo.com/"; // Act ProducerModel producer = new ProducerModel() { Name = Name, URL = URL }; // Assert Assert.Equal(Name, producer.Name); Assert.Equal(URL, producer.URL); }
public async Task <IActionResult> Post([FromBody] ProducerModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var producer = new Producer { Name = model.Name, Sex = model.Sex, DOB = model.DOB, BIO = model.BIO }; await _producerRepository.InsertAsync(producer); return(Created($"producers/{producer.Id}", producer)); }
public async Task <OperationResult> Update(ProducerModel producerModel) { var producer = await _dbContext.Producers.SingleOrDefaultAsync(x => x.Id == producerModel.Id); if (producer != null) { producer.Name = producerModel.Name; producer.Description = producerModel.Description; producer.Address = producerModel.Address; producer.ForeignId = producerModel.ForeignId; producer.City = producerModel.City; producer.ZipCode = producerModel.ZipCode; producer.Phone = producerModel.Phone; producer.ContactPerson = producerModel.ContactPerson; } await producer.Update(_dbContext); return(new OperationResult(true)); }
public async Task <IActionResult> Get(int id) { var producer = await _producerRepository.GetAsync(id); if (producer == null) { return(NotFound()); } var result = new ProducerModel { Id = producer.Id, Name = producer.Name, Sex = producer.Sex, DOB = producer.DOB, BIO = producer.BIO }; return(Ok(result)); }
public void ConvertProducerModelToProducerEntity_CheckProperties() { // Arrange string Name = "FESTO"; string URL = "https://festo.com/"; ProducerModel producer = new ProducerModel() { Name = Name, URL = URL }; // Act var producerEntity = producer.ConvertToProducerEntity(); // Assert Assert.True(producerEntity.GetType() == typeof(DataAccess.Entities.Producer)); Assert.Equal(Name, producerEntity.Name); Assert.Equal(URL, producerEntity.URL); }
public async void SaveNewProducer() { var producer = new ProducerModel { Name = ProducerName, URL = URL }; var producerValidator = new ProducerValidator(); var result = producerValidator.Validate(producer); // For tests NewProducerValidationResult = result.IsValid; if (result.IsValid) { var producerEntity = producer.ConvertToProducerEntity(); SaveNewProducerResult = await _producerAccess.AddProducer(producerEntity); SnackbarNotification.MessageQueue = new SnackbarMessageQueue(); string message = null; if (SaveNewProducerResult) { message = "Producent dodany poprawnie."; } else { message = "Producent nie zostal dodany"; } SnackbarNotification.MessageQueue.Enqueue(message); ClearProducerForm(); await LoadProducers(); } else { SnackbarNotification.MessageQueue = new SnackbarMessageQueue(); SnackbarNotification.MessageQueue.Enqueue("Błąd wprowadzonych danych, producent nie został dodany."); } }
public ActionResult Edit(int id, PRODUCER producer) { try { if (ModelState.IsValid) { ProducerModel.Update(producer); ViewBag.Message = SuccessMessage.PRODUCER_EDITED; } else { ViewBag.ErrorMessage = ErrorMessage.REQUIRED_ASTERIC_FIELDS; } return(View()); } catch { ViewBag.ErrorMessage = ErrorMessage.INTERNAL_ERROR; return(View()); } }
public ActionResult Create([Bind(Include = "Producer_Id,Producer_Name,Producer_Photo,Producer_Sex,Producer_DOB,Producer_Bio,Producer_Photo_Data")] ProducerModel ProducerModel) { try { if (ModelState.IsValid) { if (ProducerModel.Producer_Photo_Data == null) { ViewBag.FileStatus = "Please select image."; return(View(ProducerModel)); } else { ProducerModel.Producer_Photo = ProducerModel.Producer_Photo_Data.FileName; String path = Server.MapPath("Image"); String filename = Path.GetFileName(ProducerModel.Producer_Photo_Data.FileName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } else { String fullpath = Path.Combine(path, filename); ProducerModel.Producer_Photo_Data.SaveAs(fullpath); } } _ProducerRep.AddProducer(ProducerModel); _ProducerRep.save(); return(RedirectToAction("Index")); } } catch (DataException e) { ViewBag.FileStatus = e; ModelState.AddModelError("", "Unable to save changes."); } return(View(ProducerModel)); }
private void initialiseViewBag(int id = 0) { if (id == 0) { ViewBag.Authors = new MultiSelectList(AuthorModel.GetAuthors(), "AUTHORID", "ALIASNAME"); ViewBag.PRODUCERID = new SelectList(ProducerModel.GetProducers(), "PRODUCERID", "NAME"); ViewBag.Categories = new MultiSelectList(CategoryModel.GetAllCategory(), "CATEGORYID", "NAME"); ViewBag.GENREID = new SelectList(GenreModel.GetGenre(), "GENREID", "NAME"); ViewBag.LANGUAGEID = new SelectList(LanguageModel.GetLanguages(), "LANGUAGEID", "LANGUAGE1"); ViewBag.TRANSLATEDFROM = new SelectList(BookModel.getApprovedBooks(), "BOOKID", "NAME"); } else { BOOK book = BookModel.FilterBook(id); ViewBag.Authors = new MultiSelectList(AuthorModel.GetAuthors(), "AUTHORID", "ALIASNAME"); ViewBag.PRODUCERID = new SelectList(ProducerModel.GetProducers(), "PRODUCERID", "NAME", book.PRODUCER); ViewBag.Categories = new MultiSelectList(CategoryModel.GetAllCategory(), "CATEGORYID", "NAME"); ViewBag.GENREID = new SelectList(GenreModel.GetGenre(), "GENREID", "NAME", book.GENREID); ViewBag.LANGUAGEID = new SelectList(LanguageModel.GetLanguages(), "LANGUAGEID", "LANGUAGE1", book.LANGUAGEID); ViewBag.TRANSLATEDFROM = new SelectList(BookModel.getApprovedBooks(), "BOOKID", "NAME", book.TRANSLATEDFROM); } }
public ActionResult Create(ProducerModel producer) { using (var ctx = new IMDBEntities()) { if (producer.ID == 0) { var newProducer = ctx.Producers.Add(Mapper.Map <ProducerModel, Producer>(producer)); newProducer.IsDeleted = false; } else { var existProducer = ctx.Producers.FirstOrDefault(p => p.ID == producer.ID); if (existProducer != null) { existProducer.IsDeleted = false; Mapper.Map(producer, existProducer); } } ctx.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult ProducerList(string sortingOrder, string sortingDir, string searchText, string filterValue, int?pageNo) { ProducerModel model = new ProducerModel(); try { ViewBag.CurrentSortOrder = sortingOrder; if (string.IsNullOrEmpty(sortingDir)) { sortingDir = "ASC"; } if (pageNo == null) { pageNo = 1; } ViewBag.sortingDir = sortingDir; if (searchText != null) { pageNo = 1; } else { searchText = filterValue; } ViewBag.FilterValue = searchText; model.GetAllProducers(model, sortingOrder, sortingDir, searchText); int pageSize = 3; int pageNumber = (pageNo ?? 1); return(View(model.Producers.ToPagedList(pageNumber, pageSize))); } catch (Exception ex) { } return(View(model.Producers.ToPagedList(1, 3))); }
public async Task <IActionResult> Put(int id, [FromBody] ProducerModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var producer = await _producerRepository.GetAsync(id); if (producer == null) { return(NotFound()); } producer.Name = model.Name; producer.Sex = model.Sex; producer.DOB = model.DOB; producer.BIO = model.BIO; await _producerRepository.UpdateAsync(producer); return(Ok(producer)); }
public static ProducerModel ComposeValues(ProducerModel producer, JToken headers, JToken producerObj) { if (int.TryParse(headers[0]["headerValue"].ToString(), out var locationId)) { producer.Name = producerObj[locationId].ToString(); // NAme } if (int.TryParse(headers[1]["headerValue"].ToString(), out locationId)) { producer.Description = producerObj[locationId].ToString(); //Description } if (int.TryParse(headers[2]["headerValue"].ToString(), out locationId)) { producer.ForeignId = producerObj[locationId].ToString(); //Foreign Id } if (int.TryParse(headers[3]["headerValue"].ToString(), out locationId)) { producer.Address = producerObj[locationId].ToString(); //Address } if (int.TryParse(headers[5]["headerValue"].ToString(), out locationId)) { producer.City = producerObj[locationId].ToString(); //City } if (int.TryParse(headers[5]["headerValue"].ToString(), out locationId)) { producer.ZipCode = producerObj[locationId].ToString(); //ZipCode } if (int.TryParse(headers[5]["headerValue"].ToString(), out locationId)) { producer.Phone = producerObj[locationId].ToString(); //Phone } if (int.TryParse(headers[5]["headerValue"].ToString(), out locationId)) { producer.ContactPerson = producerObj[locationId].ToString(); //Contact Person } return(producer); }
public async Task <IActionResult> Create(ProducerCreateViewModel viewModel) { if (ModelState.IsValid) { try { ProducerModel producer = new ProducerModel { Name = viewModel.Name, Address = viewModel.Address }; _producerService.Create(producer); return(RedirectToAction("Index")); } catch { return(View(viewModel)); } } else { return(View(viewModel)); } }
public HttpResponseMessage Post(ProducerModel producerData) { return(Request.CreateResponse(HttpStatusCode.OK, iProducer.AddNewProducer(producerData))); }