public async Task <IActionResult> PutEmployeeCertificate([FromRoute] int id, [FromBody] EmployeeCertificate employeeCertificate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employeeCertificate.EmployeeCertificateId) { return(BadRequest()); } employeeCertificate.File = GetFile(); _context.Entry(employeeCertificate).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeCertificateExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostEmployeeCertificate([FromBody] EmployeeCertificate employeeCertificate) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } employeeCertificate.File = GetFile(); _context.EmployeeCertificates.Add(employeeCertificate); await _context.SaveChangesAsync(); return(CreatedAtAction("GetEmployeeCertificate", new { id = employeeCertificate.EmployeeCertificateId }, employeeCertificate)); }
public HomeBartender(SimDescription sim, EmployeeCertificate bar) { this.mWorld = GameUtils.GetCurrentWorld(); this.mType = RoleType.Bartender; this.mSim = sim; this.mRoleGivingObject = bar; this.mSim.AssignedRole = this; // float hourOfDay; // float hourOfDay2; // roleGiverExtended.GetRoleTimes(out hourOfDay, out hourOfDay2); SetAlarms(19, 2); ValidateAndSetupOutfit(); debugger.Debug(this, "role created for " + sim.FullName); }
public void DeleteSkill(string index) { try { //Step 1 Code to delete the object from the database EmployeeCertificate n = new EmployeeCertificate(); n.recordId = index; n.clId = 0; n.employeeId = Convert.ToInt32(CurrentEmployee.Text); n.dateFrom = DateTime.Now; n.dateTo = DateTime.Now; n.grade = "0"; n.institution = ""; n.major = ""; PostRequest <EmployeeCertificate> req = new PostRequest <EmployeeCertificate>(); req.entity = n; PostResponse <EmployeeCertificate> res = _employeeService.ChildDelete <EmployeeCertificate>(req); if (!res.Success) { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, res.Summary).Show(); return; } else { //Step 2 : remove the object from the store skillStore.Remove(index); //Step 3 : Showing a notification for the user Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordDeletedSucc }); } } catch (Exception ex) { //In case of error, showing a message box to the user X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show(); } }
protected void PoPuP(object sender, DirectEventArgs e) { int id = Convert.ToInt32(e.ExtraParams["id"]); string type = e.ExtraParams["type"]; string path = e.ExtraParams["path"]; switch (type) { case "imgEdit": //Step 1 : get the object from the Web Service EmployeeCertificate entity = GetById(id.ToString()); //Step 2 : call setvalues with the retrieved object this.SkillsForm.SetValues(entity); FillCertificateLevels(); clId.Select(entity.clId.ToString()); this.EditSkillWindow.Title = Resources.Common.EditWindowsTitle; this.EditSkillWindow.Show(); break; case "imgDelete": X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { //We are call a direct request metho for deleting a record Handler = String.Format("App.direct.DeleteSkill({0})", id), Text = Resources.Common.Yes }, No = new MessageBoxButtonConfig { Text = Resources.Common.No } }).Show(); break; default: break; } }
public IActionResult AddCertificate(AddCertificateViewModel model) { if (ModelState.IsValid) { EmployeeCertificate newCertificate = new EmployeeCertificate { EmployeeId = model.EmployeeId, Name = model.Name, Provider = model.Provider, Date = model.Date, Notes = model.Notes }; _employeeRepository.AddEmpCertificate(newCertificate); var successMessage = "Certificate Info Updated Successfully. Name: " + newCertificate.EmployeeId; TempData["successAlert"] = successMessage; // return RedirectToAction(successMessage,""); return(PartialView("_PartialMessage")); } return(View()); }
protected void SaveDocument(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string id = e.ExtraParams["id"]; string obj = e.ExtraParams["values"]; EmployeeCertificate b = JsonConvert.DeserializeObject <EmployeeCertificate>(obj); b.employeeId = Convert.ToInt32(CurrentEmployee.Text); b.recordId = id; // Define the object to add or edit as null b.clName = clId.SelectedItem.Text; if (b.dateFrom != null) { DateTime Date = (DateTime)b.dateFrom; b.dateFrom = new DateTime(Date.Year, Date.Month, Date.Day, 14, 0, 0); } if (b.dateTo != null) { DateTime Date = (DateTime)b.dateTo; b.dateTo = new DateTime(Date.Year, Date.Month, Date.Day, 14, 0, 0); } if (string.IsNullOrEmpty(id)) { try { //New Mode PostRequest <EmployeeCertificate> request = new PostRequest <EmployeeCertificate>(); request.entity = b; PostResponse <EmployeeCertificate> r = _employeeService.ChildAddOrUpdate <EmployeeCertificate>(request); b.recordId = r.recordId; //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Add this record to the store this.skillStore.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditSkillWindow.Close(); RowSelectionModel sm = this.skillsGrid.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { int index = Convert.ToInt32(id);//getting the id of the record PostRequest <EmployeeCertificate> request = new PostRequest <EmployeeCertificate>(); request.entity = b; PostResponse <EmployeeCertificate> r = _employeeService.ChildAddOrUpdate <EmployeeCertificate>(request); //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { ModelProxy record = this.skillStore.GetById(index); SkillsForm.UpdateRecord(record); record.Set("clName", b.clName); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditSkillWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
public EmployeeCertificate AddEmpCertificate(EmployeeCertificate certificate) { _context.EmployeeCertificates.Add(certificate); _context.SaveChanges(); return(certificate); }