public ActionResult Save(Staff staffentity) { bool status = false; var message = ""; //Validation try { if (staffentity != null) { var staffobj = _staffRepository.GetByID(staffentity.ID); if (staffobj != null) { staffobj.Name = staffentity.Name; staffobj.Location = staffentity.Location; _staffRepository.Update(staffobj); status = true; } else { _staffRepository.Add(staffentity); status = true; } } } catch (Exception e) { status = false; message = e.Message; } return(new JsonResult { Data = new { status = status, msg = message } }); }
private void btnSave_Click(object sender, EventArgs e) { //Staffs tablosuna girilen veriler girilecek cmbStaffType'da MutfakElemanı->StaffTypeID2 Garson->StaffTypeID3 Vale->StaffTypeID4 try { Staff staff = new Staff(); staff.StaffName = txtStaffName.Text; staff.StaffSurname = txtStaffSurname.Text; staff.StaffPhone = txtStaffPhoneMasked.Text; if (cmbBranch.SelectedIndex == 0) { staff.StaffBranchID = 1; } else if (cmbBranch.SelectedIndex == 1) { staff.StaffBranchID = 2; } else if (cmbBranch.SelectedIndex == 2) { staff.StaffBranchID = 3; } if (cmbStaffType.SelectedIndex == 0) { staff.StaffTypeID = 2; } else if (cmbStaffType.SelectedIndex == 1) { staff.StaffTypeID = 3; } else if (cmbStaffType.SelectedIndex == 2) { staff.StaffTypeID = 4; } if (cmbGender.SelectedIndex == 0) { staff.StaffGender = "Kadın"; } else if (cmbGender.SelectedIndex == 1) { staff.StaffGender = "Erkek"; } staff.CreatorID = 2; staff.CreatDate = DateTime.Now; StaffRepository staffRepository = new StaffRepository(); staffRepository.Add(staff); MessageBox.Show("Kayıt Başarılı Bir Şekilde Oluştu."); } catch { MessageBox.Show("Bir sorun oluştu lütfen bilgileri doğru giriniz"); } }
/// <summary> /// Creates staffs /// </summary> /// <param name="request">request to create staff</param> /// <returns>returns response of the operation</returns> public CreateStaffResponse CreateStaff(CreateStaffRequest request) { // Map request to entities var staffEntities = request.Staffs.Select(staff => new StaffEntity { ID = staff.ID, WorkplaceID = staff.WorkPlaceID }); //Add staffs _staffRepository.Add(staffEntities); return(new CreateStaffResponse()); }
public BaseResponse <int> AddStaff(ComplexStaff model) { Staff obj = new Staff(); obj.StaffCode = model.StaffCode; obj.FirstName = model.FirstName; obj.LastName = model.LastName; obj.FullName = model.FullName; obj.UserId = model.UserId; obj.Email = model.Email; obj.PhoneNumber = model.PhoneNumber; obj.DateOfBirth = model.DateOfBirth; obj.Gender = model.Gender; obj.Address = model.Address; obj.Avatar = model.Avatar; obj.Order = model.Order; obj.Leader = model.Leader; obj.SeniorLeader = model.SeniorLeader; obj.SuperLeader = model.SuperLeader; obj.SignedBy = model.SignedBy; obj.Active = model.Active; obj.Deleted = model.Deleted; obj.CreatedBy = model.CreatedBy; obj.CreatedOn = model.CreatedOn; obj.EditedBy = model.EditedBy; obj.EditedOn = model.EditedOn; var response = new BaseResponse <int>(); var responseTemp = new BaseResponse <Staff>(); #region Generate TaskCode string taskCode = ""; string taskCodeText = ""; string taskCodeNumber = ""; try { var systemConfigDepartmentQuery = new SystemConfigDepartmentQuery(); systemConfigDepartmentQuery.DepartmentId = model.DepartmentId; systemConfigDepartmentQuery.DefaultValue = "CB"; systemConfigDepartmentQuery.Title = "STAFFCODE"; taskCodeText = _systemConfigDepartmentRepository.GetSystemConfigDepartmentValue(systemConfigDepartmentQuery); systemConfigDepartmentQuery.DefaultValue = "0"; systemConfigDepartmentQuery.Title = "STAFFNUMBER"; string taskCodeNumberConfig = _systemConfigDepartmentRepository.GetSystemConfigDepartmentValue(systemConfigDepartmentQuery); taskCodeNumber = (int.Parse(taskCodeNumberConfig) + 1).ToString("D4"); taskCode = taskCodeText + taskCodeNumber; } catch { } #endregion Generate TaskCode try { obj.CreatedOn = DateTime.Now; responseTemp.Value = _staffRepository.Add(obj); response.Value = responseTemp.Value.Id; _applicationLoggingRepository.Log("EVENT", "ADD", "Staff", "", "", "", obj, "", HttpContext.Current.Request.UserHostAddress, obj.CreatedBy); //Update SystemConfigDepartment SystemConfigDepartment taskCodeNumberSystemConfigDepartment = new SystemConfigDepartment(); taskCodeNumberSystemConfigDepartment = _systemConfigDepartmentRepository.GetByTitle("STAFFNUMBER", model.DepartmentId); if (taskCodeNumberSystemConfigDepartment != null) { taskCodeNumberSystemConfigDepartment.Value = taskCodeNumber; _systemConfigDepartmentRepository.Edit(taskCodeNumberSystemConfigDepartment); } } catch (Exception ex) { response.IsSuccess = false; response.Message = "Error: " + ex.Message + " StackTrace: " + ex.StackTrace; } return(response); }