public async Task Update_Visitor() { VisitorDTO visitor = new VisitorDTO { Id = 2, Name = "new Name", Nationality = "nat1", Gender = "Мужчина", DateInSystem = new DateTime(2018, 07, 02), UserInSystem = "Test", DateEdit = DateTime.Now, UserEdit = "new user" }; var result = await Service.Update(visitor); var resVisitor = await Service.GetByIdAsync(2); var count = Service.GetAll().Count(); Assert.IsTrue(result.Succedeed); Assert.AreEqual(2, count); Assert.AreEqual("new Name", resVisitor.Name); Assert.AreEqual("Test", resVisitor.UserInSystem); Assert.AreEqual(new DateTime(2018, 07, 02).Date, resVisitor.DateInSystem.Value.Date); Assert.AreEqual("new user", resVisitor.UserEdit); Assert.AreEqual(DateTime.Now.Date, resVisitor.DateEdit.Value.Date); Assert.AreEqual("Мужчина", resVisitor.Gender); Assert.AreEqual("nat1", resVisitor.Nationality); }
public async Task Create_Group() { VisitorDTO visitor1 = new VisitorDTO { Id = 111, Name = "visitor1", Nationality = "nat1", Gender = "Мужчина", UserInSystem = "Test1" }; VisitorDTO visitor2 = new VisitorDTO { Id = 222, Name = "visitor2", Nationality = "nat2", Gender = "Мужчина", UserInSystem = "Test1" }; VisitorDTO visitor3 = new VisitorDTO { Id = 333, Name = "visitor3", Nationality = "nat3", Gender = "Женщина", UserInSystem = "Test1" }; GroupVisitorDTO group1 = new GroupVisitorDTO { Id = 111, CheckPoint = "check1", DateArrival = new DateTime(2018, 1, 1), Visitors = new List <VisitorDTO> { visitor1, visitor2 }, DateInSystem = DateTime.Now, UserInSystem = "Test1" }; GroupVisitorDTO group2 = new GroupVisitorDTO { Id = 222, CheckPoint = "check2", DateArrival = new DateTime(2018, 1, 2), Visitors = new List <VisitorDTO> { visitor3 }, DateInSystem = DateTime.Now, UserInSystem = "Test1" }; var result1 = await Service.Create(group1); var result2 = await Service.Create(group2); var count = Service.GetAll().Count(); var addedGroup1 = await Service.GetByIdAsync(111); var addedGroup2 = await Service.GetByIdAsync(222); var dispatch1 = await database.XMLDispatchManager.GetByIdAsync(111); var dispatch2 = await database.XMLDispatchManager.GetByIdAsync(333); Assert.IsTrue(result1.Succedeed); Assert.IsTrue(result2.Succedeed); Assert.AreEqual(4, count); Assert.AreEqual(Status.New, dispatch1.Status); Assert.AreEqual(Operation.Add, dispatch1.Operation); Assert.AreEqual(Status.New, dispatch2.Status); Assert.AreEqual(Operation.Add, dispatch2.Operation); }
public async Task Create_Visitor() { VisitorDTO visitor1 = new VisitorDTO { Id = 111, Name = "newTest", Nationality = "nat1", Gender = "Мужчина", UserInSystem = "Test1", DateInSystem = DateTime.Now }; VisitorDTO visitor2 = new VisitorDTO { Id = 222, Name = "newTest", Nationality = "nat1", Gender = "Error", UserInSystem = "Test1", DateInSystem = DateTime.Now }; var result1 = await Service.Create(visitor1); var result2 = await Service.Create(visitor2); var count = Service.GetAll().Count(); var addedVisitor1 = await Service.GetByIdAsync(111); var addedVisitor2 = await Service.GetByIdAsync(222); var dispatch1 = await database.XMLDispatchManager.GetByIdAsync(111); var dispatch2 = await database.XMLDispatchManager.GetByIdAsync(222); Assert.IsTrue(result1.Succedeed); Assert.IsTrue(result2.Succedeed); Assert.AreEqual(4, count); Assert.AreEqual(Status.New, dispatch1.Status); Assert.AreEqual(Operation.Add, dispatch1.Operation); }
public async Task Create_Visitor() { VisitorDTO visitor1 = new VisitorDTO { Id = 111, Name = "newTest", Nationality = "nat1", Gender = "Мужчина", UserInSystem = "Test1", DateInSystem = DateTime.Now }; VisitorDTO visitor2 = new VisitorDTO { Id = 222, Name = "newTest", Nationality = "nat1", Gender = "Error", UserInSystem = "Test1", DateInSystem = DateTime.Now }; var result1 = await Service.Create(visitor1); var result2 = await Service.Create(visitor2); var count = Service.GetAll().Count(); var addedVisitor1 = await Service.GetByIdAsync(111); var addedVisitor2 = await Service.GetByIdAsync(222); Assert.IsTrue(result1.Succedeed); Assert.IsTrue(result2.Succedeed); Assert.AreEqual(4, count); Assert.AreEqual("Мужчина", addedVisitor1.Gender); Assert.IsNull(addedVisitor2.Gender); Assert.IsFalse(addedVisitor1.Arrived); Assert.AreEqual(DateTime.Now.Date, addedVisitor1.DateInSystem.Value.Date); }
private async Task RecdVisitor(VisitorDTO visitor) { Visitor v = new Visitor { Id = visitor.Id }; await xmlDispatcherService.Recd(v); }
public VisitorDTO AddOrUpdateVisitor(VisitorDTO visitorDTO) { Visitor visitor = mapper.Map <Visitor>(visitorDTO); if (visitor != null) { visitorDTO = mapper.Map <VisitorDTO>(visitorRepository.AddOrUpdateVisitor(visitor)); } return(visitorDTO); }
public bool RemoveVisitorDTO(VisitorDTO visitorDTO) { bool result; try { visitorRepository.RemoveVisitor(mapper.Map <Visitor>(visitorDTO)); result = true; } catch { result = false; } return(result); }
public async Task Update_Visitor() { VisitorDTO visitor = new VisitorDTO { Id = 2, Name = "new Name", Nationality = "nat2" }; var result = await Service.Update(visitor); var dispatch = await database.XMLDispatchManager.GetByIdAsync(2); Assert.AreEqual(Status.Send, dispatch.Status); Assert.AreEqual(Operation.Edit, dispatch.Operation); }
public IActionResult Register([FromBody] VisitorDTO userDTO) { //map dto to entity var user = _mapper.Map <Visitors>(userDTO); try { //save _userService.Create(user, userDTO.Email); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }
/// <summary> /// Converts this instance of <see cref="Visitor"/> to an instance of <see cref="VisitorDTO"/>. /// </summary> /// <param name="entity"><see cref="Visitor"/> to convert.</param> public static VisitorDTO ToDTO(this Visitor entity) { if (entity == null) { return(null); } var dto = new VisitorDTO(); dto.ID = entity.ID; dto.FirstName = entity.FirstName; dto.LastName = entity.LastName; dto.PersonIDCardNumber = entity.PersonIDCardNumber; dto.CreatedByUserID = entity.CreatedByUserID; dto.CreatedDate = entity.CreatedDate; dto.ModifiedByUserID = entity.ModifiedByUserID; dto.ModifiedDate = entity.ModifiedDate; entity.OnDTO(dto); return(dto); }
/// <summary> /// Converts this instance of <see cref="VisitorDTO"/> to an instance of <see cref="Visitor"/>. /// </summary> /// <param name="dto"><see cref="VisitorDTO"/> to convert.</param> public static Visitor ToEntity(this VisitorDTO dto) { if (dto == null) { return(null); } var entity = new Visitor(); entity.ID = dto.ID; entity.FirstName = dto.FirstName; entity.LastName = dto.LastName; entity.PersonIDCardNumber = dto.PersonIDCardNumber; entity.CreatedByUserID = dto.CreatedByUserID; entity.CreatedDate = dto.CreatedDate; entity.ModifiedByUserID = dto.ModifiedByUserID; entity.ModifiedDate = dto.ModifiedDate; dto.OnEntity(entity); return(entity); }
static void Main(string[] args) { ServiceExecutor serviceExecutor = new ServiceExecutor(); serviceExecutor.statusChanged += DisplayStatus; Task.Factory.StartNew(serviceExecutor.Start); Thread.Sleep(1000); // for (int i = 0; i < 100; i++) //{ // Console.WriteLine(i); // Thread.Sleep(1000); //} ClientExecutor clientExecutor = new ClientExecutor(); VisitorDTO v = new VisitorDTO { Column1 = "Первая колонка" }; VisitorDTO v1 = new VisitorDTO { Column1 = "Вторая лолонка", Column2 = "Вторая колонка" }; clientExecutor.GetClient().AddOrUpdateVisitor(v); clientExecutor.GetClient().AddOrUpdateVisitor(v); clientExecutor.GetClient().AddOrUpdateVisitor(v1); Thread.Sleep(1000); var cv = clientExecutor.GetClient().GetAllVisitors(); foreach (var c in cv) { Console.WriteLine(c.Column1 + " - " + (c.Column2 == null?"n":c.Column2)); } for (int i = 1; i < 200; i++) { Thread.Sleep(1000); Console.WriteLine(i); } }
public bool UpdateVisitor(int visitorID, VisitorDTO visitorDTO) { throw new NotImplementedException(); }
public int CreateVisitor(VisitorDTO visitorDTO) { throw new NotImplementedException(); }
public void AddOrUpdateVisitor(VisitorDTO visitor) { visitorRepositoryDTO.AddOrUpdateVisitor(visitor); }
public IActionResult Login([FromBody] VisitorDTO visitorDTO) { _userService.Login(visitorDTO.Email); return(Ok("Successful Login")); }
public VisitorDTO AddOrUpdateVisitor(VisitorDTO visitor) { return(visitorRepositoryDTO.AddOrUpdateVisitor(visitor)); }
// SaveFileDialog sfd = new SaveFileDialog(); // DialogResult res = sfd.ShowDialog(); //if (res == DialogResult.OK) //{ // string path = sfd.FileName + ".xlsx"; // Microsoft.Office.Interop.Excel.Application exelapp = new Microsoft.Office.Interop.Excel.Application(); // Microsoft.Office.Interop.Excel.Workbook workbook = exelapp.Workbooks.Add(); // Microsoft.Office.Interop.Excel.Worksheet worksheet = workbook.ActiveSheet; // pb.Visible = true; // pb.Maximum = dgv_visitors.RowCount-1; // worksheet.Rows[1].Columns[1] = "Имя"; // worksheet.Rows[1].Columns[2] = "Фамилия"; // worksheet.Rows[1].Columns[3] = "Отчество"; // worksheet.Rows[1].Columns[4] = "Компания"; // worksheet.Rows[1].Columns[5] = "Должность"; // worksheet.Rows[1].Columns[6] = "Штрихкод"; // worksheet.Rows[1].Columns[7] = "Вы являетесь"; // worksheet.Rows[1].Columns[8] = "Телефон мобильный"; // worksheet.Rows[1].Columns[9] = "Телефон рабочий"; // worksheet.Rows[1].Columns[10] = "E-Mail"; // worksheet.Rows[1].Columns[11] = "Дата"; // worksheet.Rows[1].Columns[12] = "Выставка"; // worksheet.Rows[1].Columns[13] = "Доклад"; // worksheet.Rows[1].Columns[14] = "Город"; // for (int i = 1; i<dgv_visitors.RowCount; i++) // { // pb.Value = i; // worksheet.Rows[i + 1].Columns[1] = dgv_visitors.Rows[i - 1].Cells[1].Value; // worksheet.Rows[i + 1].Columns[2] = dgv_visitors.Rows[i - 1].Cells[2].Value; // worksheet.Rows[i + 1].Columns[3] = dgv_visitors.Rows[i - 1].Cells[3].Value; // worksheet.Rows[i + 1].Columns[4] = dgv_visitors.Rows[i - 1].Cells[4].Value; // worksheet.Rows[i + 1].Columns[5] = dgv_visitors.Rows[i - 1].Cells[5].Value; // worksheet.Rows[i + 1].Columns[6] = dgv_visitors.Rows[i - 1].Cells[6].Value; // worksheet.Rows[i + 1].Columns[7] = dgv_visitors.Rows[i - 1].Cells[7].Value; // worksheet.Rows[i + 1].Columns[8] = dgv_visitors.Rows[i - 1].Cells[8].Value; // worksheet.Rows[i + 1].Columns[9] = dgv_visitors.Rows[i - 1].Cells[9].Value; // worksheet.Rows[i + 1].Columns[10] = dgv_visitors.Rows[i - 1].Cells[10].Value; // worksheet.Rows[i + 1].Columns[11] = dgv_visitors.Rows[i - 1].Cells[11].Value; // worksheet.Rows[i + 1].Columns[12] = dgv_visitors.Rows[i - 1].Cells[12].Value; // worksheet.Rows[i + 1].Columns[13] = dgv_visitors.Rows[i - 1].Cells[13].Value; // worksheet.Rows[i + 1].Columns[14] = dgv_visitors.Rows[i - 1].Cells[14].Value; // } // pb.Visible = false; // exelapp.AlertBeforeOverwriting = false; // workbook.SaveAs(path); // exelapp.Quit(); //} private void Button_Click_3(object sender, RoutedEventArgs e) { FileDialog openFileDialog = new OpenFileDialog(); List <VisitorDTO> addedInfVisitors; if (openFileDialog.ShowDialog() == true) { ExelData exelData = new ExelData(openFileDialog.FileName, 20); addedInfVisitors = new List <VisitorDTO>(); for (int i = 0; i < exelData.excelWorksheetRow; i++) { var nv = new VisitorDTO { Column1 = exelData.data[i, 0], Column2 = exelData.data[i, 1], Column3 = exelData.data[i, 2], Column4 = exelData.data[i, 3], Column5 = exelData.data[i, 4], Column6 = exelData.data[i, 5], Column7 = exelData.data[i, 6], Column8 = exelData.data[i, 7], Column9 = exelData.data[i, 8], Column10 = exelData.data[i, 14], Column11 = exelData.data[i, 15], Column12 = exelData.data[i, 16], Column13 = exelData.data[i, 17], Column14 = exelData.data[i, 18], Column15 = exelData.data[i, 19], CurrentStatus = "registered" }; addedInfVisitors.Add(nv); } FileDialog saveFileDialog = new SaveFileDialog(); if (saveFileDialog.ShowDialog() == true) { var path = saveFileDialog.FileName + ".xlsx"; var repv = new VisitorRepositoryDTO(); var vindb = repv.GetAllVisitors(); var reps = new StatusRepositoryDTO(); var sindb = reps.GetAllStatuses(); Microsoft.Office.Interop.Excel.Application exelapp = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook workbook = exelapp.Workbooks.Add(); Microsoft.Office.Interop.Excel.Worksheet worksheet = workbook.ActiveSheet; int i = 0; foreach (var stat in sindb) { var vis = vindb.Where(s => s.Id == stat.VisitorId).FirstOrDefault(); var visAddInf = addedInfVisitors.Where(s => s.Column1 == vis.Column1).FirstOrDefault(); var choice = vis.Column1.Split('-')[0]; switch (choice) { case "VHS": worksheet.Rows[i + 1].Columns[1] = vis.Column1; worksheet.Rows[i + 1].Columns[2] = vis.Column2; worksheet.Rows[i + 1].Columns[3] = vis.Column3; worksheet.Rows[i + 1].Columns[4] = vis.Column4; worksheet.Rows[i + 1].Columns[5] = vis.Column5; worksheet.Rows[i + 1].Columns[6] = stat.Name; worksheet.Rows[i + 1].Columns[7] = vis.Column7; worksheet.Rows[i + 1].Columns[8] = vis.Column8; worksheet.Rows[i + 1].Columns[9] = vis.Column9; worksheet.Rows[i + 1].Columns[10] = vis.Column10; worksheet.Rows[i + 1].Columns[11] = vis.Column11; worksheet.Rows[i + 1].Columns[12] = stat.ActionTime; worksheet.Rows[i + 1].Columns[12] = vis.Column12; worksheet.Rows[i + 1].Columns[13] = vis.Column13; worksheet.Rows[i + 1].Columns[14] = vis.Column14; worksheet.Rows[i + 1].Columns[15] = " "; worksheet.Rows[i + 1].Columns[16] = " "; worksheet.Rows[i + 1].Columns[17] = " "; worksheet.Rows[i + 1].Columns[18] = " "; worksheet.Rows[i + 1].Columns[19] = " "; worksheet.Rows[i + 1].Columns[20] = " "; worksheet.Rows[i + 1].Columns[21] = stat.ActionTime; break; default: worksheet.Rows[i + 1].Columns[1] = vis.Column1; worksheet.Rows[i + 1].Columns[2] = vis.Column2; worksheet.Rows[i + 1].Columns[3] = vis.Column3; worksheet.Rows[i + 1].Columns[4] = vis.Column4; worksheet.Rows[i + 1].Columns[5] = vis.Column5; worksheet.Rows[i + 1].Columns[6] = stat.Name; worksheet.Rows[i + 1].Columns[7] = vis.Column7; worksheet.Rows[i + 1].Columns[8] = vis.Column8; worksheet.Rows[i + 1].Columns[9] = vis.Column9; worksheet.Rows[i + 1].Columns[10] = vis.Column10; worksheet.Rows[i + 1].Columns[11] = vis.Column11; worksheet.Rows[i + 1].Columns[12] = vis.Column12; worksheet.Rows[i + 1].Columns[13] = vis.Column13; worksheet.Rows[i + 1].Columns[14] = vis.Column14; worksheet.Rows[i + 1].Columns[15] = visAddInf.Column10; worksheet.Rows[i + 1].Columns[16] = visAddInf.Column11; worksheet.Rows[i + 1].Columns[17] = visAddInf.Column12; worksheet.Rows[i + 1].Columns[18] = visAddInf.Column13; worksheet.Rows[i + 1].Columns[19] = visAddInf.Column14; worksheet.Rows[i + 1].Columns[20] = visAddInf.Column15; switch (stat.Name) { case "registered": var temp = visAddInf.Column15; var time = temp.Replace("T", " "); var time_correct = time.Split('+')[0] + ":00"; worksheet.Rows[i + 1].Columns[21] = time_correct; break; default: worksheet.Rows[i + 1].Columns[21] = stat.ActionTime; break; } // worksheet.Rows[i + 1].Columns[21] = stat.ActionTime; break; } i++; } exelapp.AlertBeforeOverwriting = false; workbook.SaveAs(path); exelapp.Quit(); } } }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="entity"><see cref="Visitor"/> converted from <see cref="VisitorDTO"/>.</param> static partial void OnEntity(this VisitorDTO dto, Visitor entity);
public void RemoveVisitor(VisitorDTO visitor) { visitorRepositoryDTO.RemoveVisitorDTO(visitor); }
/// <summary> /// Invoked when <see cref="ToDTO"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="VisitorDTO"/> converted from <see cref="Visitor"/>.</param> static partial void OnDTO(this Visitor entity, VisitorDTO dto);