protected virtual async Task Create(CreateOrEditQuyTrinhCongTacDto input) { var quyTrinhCongTac = ObjectMapper.Map <QuyTrinhCongTac>(input); await _quyTrinhCongTacRepository.InsertAsync(quyTrinhCongTac); }
public async Task <int> CreateForMobile(CreateOrEditQuyTrinhCongTacDto input) { try { var branchId = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == input.CreatorUserId); if (branchId.BRANCH_ID.Equals("1")) { Logger.Error("Tổng Giám Đốc ko thể đăng ký Công Tác"); return(0); } var conn = new SqlConnection(_connectionString); if (conn.State == ConnectionState.Closed) { conn.Open(); } var parameters = new DynamicParameters(); parameters.Add("@branchId", branchId.BRANCH_ID); var lstUserListDtos = await conn.QueryAsync <UserListDto>("GetUserByParentFather", parameters, null, null, CommandType.StoredProcedure); var userListDtos = lstUserListDtos.ToList(); if (userListDtos.Any()) { input.QuanLyTrucTiep = userListDtos.Find(x => x.BRANCH_TYPE.Equals("TN"))?.EmployeeCode; input.TruongBoPhanId = userListDtos.Find(x => x.BRANCH_TYPE.Equals("CN"))?.EmployeeCode; input.GiamDocBoPhanId = userListDtos.Find(x => x.BRANCH_TYPE.Equals("KV"))?.EmployeeCode; input.GiamDocId = userListDtos.Find(x => x.BRANCH_TYPE.Equals("HS"))?.EmployeeCode; if (input.QuanLyTrucTiep != null) { input.NguoiDuyetId = input.QuanLyTrucTiep; } else if (input.TruongBoPhanId != null) { input.NguoiDuyetId = input.TruongBoPhanId; } else if (input.GiamDocBoPhanId != null) { input.NguoiDuyetId = input.GiamDocBoPhanId; } else { input.NguoiDuyetId = input.GiamDocId; } //input.PhongCTNSId = userListDtos.Count >= ? userListDtos[3].EmployeeCode : null; } var quyTrinhCongTac = ObjectMapper.Map <QuyTrinhCongTac>(input); return(await _quyTrinhCongTacRepository.InsertAndGetIdAsync(quyTrinhCongTac)); } catch (Exception e) { Logger.Error(e.Message, e); return(0); } }
public async Task CreateOrEdit(CreateOrEditQuyTrinhCongTacDto input) { if (input.Id == null) { await Create(input); } else { await Update(input); } }
//public List<QuyTrinhCongTacDto> GetAllQuyTrinhCongTacList(int id) //{ // return _quyTrinhCongTacRepository.GetAll().Where(t => t.IsDeleted == false).Select(t => new QuyTrinhCongTacDto { Id=t.Id , MaHoSo = t.MaHoSo }).ToList(); //} public async Task CreateOrEdit(CreateOrEditQuyTrinhCongTacDto input) { try { if (input.Id == null) { await Create(input); } else { await Update(input); } } catch (Exception e) { Logger.Warn(e.Message, e); } }
public async Task <int> EditForMobile(CreateOrEditQuyTrinhCongTacDto input) { try { var quyTrinhCongTac = await _quyTrinhCongTacRepository.FirstOrDefaultAsync(x => x.Id == input.Id.Value); quyTrinhCongTac.NgayDuyet = input.NgayDuyet; quyTrinhCongTac.GhiChu = input.GhiChu; if (quyTrinhCongTac.NguoiDuyetId.Equals(quyTrinhCongTac.QuanLyTrucTiep) && !string.IsNullOrEmpty(quyTrinhCongTac.TruongBoPhanId)) { quyTrinhCongTac.NguoiDuyetId = quyTrinhCongTac.TruongBoPhanId; } else if (quyTrinhCongTac.NguoiDuyetId.Equals(quyTrinhCongTac.TruongBoPhanId) && !string.IsNullOrEmpty(quyTrinhCongTac.GiamDocBoPhanId)) { quyTrinhCongTac.NguoiDuyetId = quyTrinhCongTac.GiamDocBoPhanId; } else if (quyTrinhCongTac.NguoiDuyetId.Equals(quyTrinhCongTac.GiamDocBoPhanId) && !string.IsNullOrEmpty(quyTrinhCongTac.GiamDocId)) { quyTrinhCongTac.NguoiDuyetId = quyTrinhCongTac.GiamDocId; } //else if (quyTrinhCongTac.NguoiDuyetId.Equals(input.QuanLyTrucTiep)) //{ // quyTrinhCongTac.NguoiDuyetId = input.QuanLyTrucTiep; //} //var getFather_Id = _userManager.Users // .Join(_branchRepository.GetAll(), u => u.BRANCH_ID, b => b.Id, (u, b) => new {u, b}) // .FirstOrDefaultAsync(x => x.u.EmployeeCode == quyTrinhCongTac.NguoiDuyetId).Result.b.FATHER_ID; //var maNV = _userManager.Users.FirstOrDefaultAsync(x => x.BRANCH_ID == getFather_Id).Result.EmployeeCode; //quyTrinhCongTac.NguoiDuyetId = maNV; await _quyTrinhCongTacRepository.UpdateAsync(quyTrinhCongTac); return(quyTrinhCongTac.Id); } catch (Exception e) { Logger.Error(e.Message, e); return(0); } }
public async Task <int> CreateOrEditForMobile(CreateOrEditQuyTrinhCongTacDto input) { try { if (DateTime.Compare(input.DateFrom, input.DateTo) < 0) { if (input.Id == null) { return(await CreateForMobile(input)); } return(await EditForMobile(input)); } throw new UserFriendlyException(L(name: "Ngày kết thúc lớn hơn ngày bắt đầu")); } catch (Exception e) { Logger.Warn(e.Message, e); } return(0); }
//[AbpAuthorize(AppPermissions.Pages_QuyTrinhCongTacs_Edit)] protected virtual async Task Update(CreateOrEditQuyTrinhCongTacDto input) { var quyTrinhCongTac = await _quyTrinhCongTacRepository.FirstOrDefaultAsync((int)input.Id); ObjectMapper.Map(input, quyTrinhCongTac); }