public ActionResult SaveTechnician(TechnicianModel model) { _log.InfoFormat("Method: SaveTechnician. Model ID: {0}", model.Id); var employee = repository.Get <SageEmployee>(model.Id); var assignment = repository.SearchFor <SageAssignment>(e => e.EmployeeId == employee.Employee).FirstOrDefault(); model.Id = employee.Employee.ToString(); var technician = Mapper.Map <SageEmployee, EmployeeModel>(employee); technician.AvailableDays = model.AvailableDays; technician.IsAvailable = model.IsAvailable; technician.Picture = model.Picture; if (model.IsAvailable == false && employee.IsAvailable) { notification.SendNotification(string.Format("Technician {0} is unavailable", employee.Name)); } if (imageService.BuildTechnicianIcons(model)) { technician.Color = model.Color; if (assignment != null) { assignment.Color = model.Color; } } var updatedTechnician = Mapper.Map <EmployeeModel, SageEmployee>(technician); repository.Update(updatedTechnician); repository.Update(assignment); hub.UpdateTechnician(model); _log.InfoFormat("Repository update technician. Name {0}, ID {1}", updatedTechnician.Name, updatedTechnician.Id); return(Success()); }
private void dvgAllTechniciansEditing_SelectionChanged(object sender, EventArgs e) { DataGridView dgv = (DataGridView)sender; try { if (dgv.SelectedRows.Count > 0) { string currentUserId = dgv.SelectedRows[0].Cells[0].Value.ToString(); userId = int.Parse(currentUserId); TechnicianModel userData = this.userService.GetTechnicianData(userId); txtTechnicianName.Text = userData.Name.ToString(); txtTechnicianSurname.Text = userData.Surname.ToString(); txtTechnicianContactNumber.Text = userData.ContactNumber.ToString(); txtTechnicianContactMail.Text = userData.Email.ToString(); txtTechnicianCompany.Text = userData.Company.ToString(); } } catch (Exception ex) { this.ShowErrorMessage(ex); } }
public async Task <IActionResult> AssignShopTech(TechnicianModel model) { AssignedTechDb assignTech = new AssignedTechDb { TechnicianId = _repo.GetShopTeches.Where(name => name.TechnicianName.Equals(model.TechName) && name.UserId.Equals(int.Parse(Request.Cookies["UserID"]))).FirstOrDefault().TechnicianId, ServiceId = _repo.GetShopServices.Where(name => name.ServiceName.Equals(model.AssignedService) && name.UserId.Equals(int.Parse(Request.Cookies["UserID"]))).FirstOrDefault().ServiceId }; bool result = await _repo.CreateAssignedTech(assignTech); if (result) { ViewBag.AssignedTechSucess = $"{model.AssignedService} Services Added to {model.TechName}"; } else { ModelState.AddModelError(string.Empty, "Couldn't Add Shop Services. Try Again With Cookies Enabled"); } return(View(new TechnicianModel { ShopServices = _repo.GetShopServices.Where(s => s.UserId.Equals(int.Parse(Request.Cookies["UserID"]))), TechDbs = _repo.GetShopTeches.Where(s => s.UserId.Equals(int.Parse(Request.Cookies["UserID"]))), UserCookie = Request.Cookies["UserID"] })); }
public void Technician_Update_Valid_Data_Good_Should_Pass() { // Arrange var myData = new TechnicianModel(); var myDataNew = new TechnicianModel { FirstName = "John", LastName = "Doe", DateOfBirth = new System.DateTime(2019, 1, 1), ClinicID = "Test", ID = myData.ID }; // Act myData.Update(myDataNew); myData.Date = myData.Date.AddSeconds(-5); // Assert Assert.AreEqual("John", myData.FirstName); Assert.AreEqual("Doe", myData.LastName); Assert.AreEqual(new System.DateTime(2019, 1, 1), myData.DateOfBirth); Assert.AreEqual("Test", myData.ClinicID); Assert.AreNotEqual(myData.Date, myDataNew.Date); }
public IActionResult Create( [Bind("" + "ID," + "Date," + "FirstName," + "LastName," + "DateOfBirth," + "ClinicID," + // TODO, Add your attributes here. Make sure to include the comma , after the attribute name "")] TechnicianModel data) { if (!ModelState.IsValid) { return(RedirectToAction("Error", "Home")); } // Todo Save Change var result = Backend.Create(data); if (result == null) { return(RedirectToAction("Error", "Home")); } return(RedirectToAction(nameof(Index))); }
private async Task LoadAsync(TechnicianModel user) { var userName = await _userManager.GetUserNameAsync(user); var phoneNumber = await _userManager.GetPhoneNumberAsync(user); IsEmailConfirmed = await _userManager.IsEmailConfirmedAsync(user); Username = userName; Input = new InputModel { PhoneNumber = phoneNumber, FirstName = user.FirstName, LastName = user.LastName, Street = user.Street, City = user.City, State = user.State, Country = user.Country, PostalCode = user.PostalCode, Bio = user.Bio, Clinic = user.ClinicID, Organization = user.OrganizationID, EulaAccepted = user.EulaAccepted }; }
public UnifyApiResult Add(TechnicianModel model) { if (model == null) { return(UnifyApiResult.Error("参数不能为空。")); } if (string.IsNullOrEmpty(model.Name)) { return(UnifyApiResult.Error("姓名不能为空。")); } if (string.IsNullOrEmpty(model.Phone)) { return(UnifyApiResult.Error("手机不能为空。")); } TechnicianDAL dal = new TechnicianDAL(); if (dal.GetData(model.Name) != null) { return(UnifyApiResult.Error("姓名不允许重复。")); } dynamic result = dal.Insert(model); return(UnifyApiResult.Sucess(result)); }
public IActionResult Update( [Bind("" + "ID," + "Date," + "FirstName," + "LastName," + "DateOfBirth," + "ClinicID," + // TODO, Add your attributes here. Make sure to include the comma , after the attribute name "")] TechnicianModel data) { if (!ModelState.IsValid) { return(NotFound()); } //Look up the ID var dataExist = Backend.Read(data.ID); if (dataExist == null) { return(NotFound()); } var dataResult = Backend.Update(data); if (dataResult == null) { return(NotFound()); } return(RedirectToAction(nameof(Index))); }
public ActionResult DeleteConfirmed(int id) { TechnicianModel technicianModel = db.TechnicianModels.Find(id); db.TechnicianModels.Remove(technicianModel); db.SaveChanges(); return(RedirectToAction("Index")); }
private void btnMalfunctionReport_Click(object sender, EventArgs e) { MalfunctionReportModel malfunctionReportModel = new MalfunctionReportModel(); //NE ZABORAVI GA INICIALIZIRAT jer ce izbacit gresku //DataRow selectedDataRow = ((DataRowView)cmbTechnicianMal.SelectedItem).Row; //int technicianId = Convert.ToInt32(selectedDataRow["Tehnician_ID"]); TechnicianModel tech = new TechnicianModel(); if (cmbTechnicianMal.SelectedItem != null) { tech = (TechnicianModel)cmbTechnicianMal.SelectedItem; } //int technicianId = selectedDataRow.Id; int technicianId = tech.Id; //label84.Text = technicianId.ToString(); malfunctionReportModel.Id = orderId; malfunctionReportModel.MalfunctionTime = Convert.ToDateTime(txtMalTime.Text); malfunctionReportModel.MalfunctionTimeEnd = Convert.ToDateTime(txtMalTimeEnd.Text); malfunctionReportModel.StateCurrent = txtStateCurrentMal.Text; malfunctionReportModel.ActionsTaken = txtActionsTakenMal.Text; malfunctionReportModel.StateAfter = txtStateAfterMal.Text; malfunctionReportModel.StatusCompleted = "Y"; malfunctionReportModel.SpareMaterial = txtSpareMaterialMal.Text; TechnicianModel technician = new TechnicianModel(); technician.Id = technicianId; malfunctionReportModel.Technician = technician; //find id of ATM , send Atm through UpdateAtmComponent var malfunctionReport = this.orderService.GetMalfunctionReportByOrderId(orderId); //int atmId = malfunctionReport.ATM.Id; //ovo mi vraca false vidit zasto //vraca false jer je stavljeno no count u proceduri var flag = this.orderService.UpdateMalfunctionOrder(malfunctionReportModel); AtmComponentModel atmComponent = new AtmComponentModel(); if (cmbComponentsMal.SelectedIndex > -1) { atmComponent.SerialNumber = txtSerialComponentMal.Text; atmComponent.Description = txtDescriptionComponentMal.Text; atmComponent.Name = cmbComponentsMal.SelectedItem.ToString(); atmComponent.Status = "Y"; var flagMal = this.atmService.UpdateAtmComponent(malfunctionReport.ATM, atmComponent); } DataTable data = this.orderService.GetAllOrdersByDate(date); this.LoadDataGridView(data); }
public async Task Insert(TechnicianModel technician) { using (HttpResponseMessage response = await _apiHelper.ApiClient.PostAsJsonAsync("/api/teknisi", technician).ConfigureAwait(false)) { if (!response.IsSuccessStatusCode) { throw await ApiException.FromHttpResponse(response); } } }
public ActionResult Edit([Bind(Include = "Id,name")] TechnicianModel technicianModel) { if (ModelState.IsValid) { db.Entry(technicianModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(technicianModel)); }
/// <summary> /// Add the Technician item to the data store /// </summary> /// <param name="data"> /// The new Technician item to add to the data store /// </param> /// <returns>return the passed in Technician item</returns> public TechnicianModel Create(TechnicianModel data, DataSourceEnum dataSourceEnum = DataSourceEnum.Unknown) { if (data == null) { return(null); } dataset.Add(data); return(data); }
public void Technician_Default_Should_Pass() { // Arrange // Act var result = new TechnicianModel(); // Assert Assert.IsNotNull(result); }
public ActionResult Create([Bind(Include = "Id,name")] TechnicianModel technicianModel) { if (ModelState.IsValid) { db.TechnicianModels.Add(technicianModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(technicianModel)); }
public void Technician_Update_InValid_Data_Null_Should_Fail() { // Arrange var myData = new TechnicianModel(); // Act var result = myData.Update(null); // Assert Assert.AreEqual(false, result); }
public TechnicianModel CreateTechnician(string name) { TechnicianModel technician = new TechnicianModel { Name = name, IsDefault = true }; EntityExtension.FlagForCreate(technician, IdentityService.Username, UserAgent); dbContext.Technicians.Add(technician); return(technician); }
public void Technician_Get_Should_Pass() { // Arrange var myData = new TechnicianModel(); // Act // Assert Assert.IsNull(myData.FirstName); Assert.IsNull(myData.LastName); Assert.IsNull(myData.DateOfBirth); Assert.IsNull(myData.ClinicID); }
private async Task LoadAsync(TechnicianModel user) { var email = await _userManager.GetEmailAsync(user); Email = email; Input = new InputModel { NewEmail = email, }; IsEmailConfirmed = await _userManager.IsEmailConfirmedAsync(user); }
/// <summary> /// Makes a new AvatarItem /// </summary> /// <param name="data"></param> /// <returns>AvatarItem Passed In</returns> public TechnicianModel Create(TechnicianModel data, DataSourceEnum dataSourceEnum = DataSourceEnum.Unknown) { if (data == null) { return(null); } dataset.Add(data); // Add to Storage var myResult = DataSourceBackendTable.Instance.Create <TechnicianModel>(tableName, partitionKey, data.ID, data, dataSourceEnum); return(data); }
// GET: Technician/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TechnicianModel technicianModel = db.TechnicianModels.Find(id); if (technicianModel == null) { return(HttpNotFound()); } return(View(technicianModel)); }
public void Technician_Create_Post_Default_Should_Pass() { // Arrange var myController = new TechnicianController(); var myData = new TechnicianModel(); // Act var result = myController.Create(myData); // Reset // Assert Assert.IsNotNull(result); }
}//End GetAllTechnicians public List <TechnicianModel> GetAllTechniciansList() { DataTable data = new DataTable(); using (SqlConnection con = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand(); SqlDataAdapter da = new SqlDataAdapter(); DataTable dt = new DataTable(); //Create Technician List List <TechnicianModel> _technicians = new List <TechnicianModel>(); try { cmd = new SqlCommand("procGetAllTechnicians", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection.Open(); da.SelectCommand = cmd; da.Fill(dt); cmd.Connection.Close(); foreach (DataRow row in dt.Rows) { TechnicianModel _technician = new TechnicianModel(); _technician.Id = Convert.ToInt32(row["Tehnician_ID"]); _technician.Name = row["Name"].ToString(); _technician.Surname = row["Surname"].ToString(); _technician.ContactNumber = row["Contact_number"].ToString(); _technician.Email = row["Contact_name"].ToString(); _technician.Company = row["Company"].ToString(); _technicians.Add(_technician); } } catch (Exception x) { MessageBox.Show(x.GetBaseException().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { cmd.Dispose(); //pl.MySQLConn.Close(); } return(_technicians); } }
public void Technician_Create_Post_Default_Should_Pass() { // Arrange var myBackend = TechnicianBackend.Instance; var myData = new TechnicianModel(); // Act var result = myBackend.Create(myData); // Reset BiliWeb.Backend.DataSourceBackend.Instance.Reset(); // Assert Assert.IsNotNull(result); }
public void Technician_Create_Post_Invalid_Model_Should_Send_Back_For_Edit() { // Arrange var controller = new TechnicianController(); var data = new TechnicianModel(); // Make ModelState Invalid controller.ModelState.AddModelError("test", "test"); // Act var result = controller.Create(data) as RedirectToActionResult; // Assert Assert.AreEqual("Error", result.ActionName); }
public void Technician_Create_InValid_Null_Should_Fail() { // Arrange var myBackend = TechnicianRepositoryMock.Instance; var myData = new TechnicianModel(); // Act var result = myBackend.Create(null); // Reset myBackend.Reset(); // Assert Assert.IsNull(result); }
public void Technician_Create_Default_Should_Pass() { // Arrange var myBackend = TechnicianRepositoryMock.Instance; var myData = new TechnicianModel(); // Act var result = myBackend.Create(myData); // Reset myBackend.Reset(); // Assert Assert.IsNotNull(result); }
public void Technician_Delete_Post_Invalid_Model_Should_Send_Back_For_Edit() { // Arrange var controller = new TechnicianController(); var data = new TechnicianModel(); // Make ModelState Invalid controller.ModelState.AddModelError("test", "test"); // Act var result = controller.DeleteConfirmed(data.ID) as NotFoundResult; // Assert Assert.AreEqual(404, result.StatusCode); }
public void Technician_Delete_Post_Empty_Id_Should_Send_Back_For_Edit() { // Arrange var controller = new TechnicianController(); TechnicianModel dataEmpty = new TechnicianModel { // Make data.Id empty ID = "" }; // Act var result = controller.DeleteConfirmed(dataEmpty.ID) as RedirectToActionResult; // Assert Assert.AreEqual("Error", result.ActionName); }
public async Task <TechnicianModel> GetById(int id) { using (HttpResponseMessage response = await _apiHelper.ApiClient.GetAsync("/api/teknisi/" + id).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { TechnicianModel result = await response.Content.ReadAsAsync <TechnicianModel>(); return(result); } else { throw await ApiException.FromHttpResponse(response); } } }