public async Task <RS_User> GetUserinCustomer(string search) { RS_User result = new RS_User(); try { var ef_linq = this.Daouser.GetCustomerInfo(search); result.Count = ef_linq.Count(); result.PageSize = pageSize; result.UserPagedlsit = await ef_linq.OrderByDescending(b => b.Id).ToPagedListAsync(1, pageSize); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_Object> UpdateCustomer(EF_Customer DataEntry) { RS_Object result = new RS_Object(); try { var Rs_Modify = await this.Daocustomer.UpdateCustomer(DataEntry); Rs_Modify.Message = Rs_Modify.Success ? $"成功更新客戶資料{Rs_Modify.Count}筆" : Rs_Modify.Message; result = Rs_Modify.Transfor("客戶"); return(result); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_Customer> GetCustomerList(int?page) { RS_Customer result = new RS_Customer(); try { var pageIndex = page ?? 1; var customers = this.Daocustomer.GetCustomers(); result.Count = customers.Count(); result.PageSize = pageSize; result.CustomerPagedlsit = await customers.ToPagedListAsync(pageIndex, pageSize); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_ModifyResult> CreateUser(EF_User DataEntry) { RS_ModifyResult result = new RS_ModifyResult("Add"); try { this.dbcontext.User.Add(this.Transfor(DataEntry)); var SaveResult = await this.dbcontext.SaveChangesAsync(); result.Count = SaveResult; result.Success = true; } catch (Exception ex) { result.Message = ex.ToString(); result.Success = false; Nlogger.WriteLog(Nlogger.NType.Error, ex.Message, ex); } return(result); }
public async Task <RS_Object> CreateCustomer(EF_Customer DataEntry) { RS_Object result = new RS_Object(); try { var Rs_Modify = await this.CheckCustomerId(DataEntry.Name.ToString()); if (Rs_Modify.Success) { Rs_Modify = await this.Daocustomer.CreateCustomer(DataEntry); Rs_Modify.Message = Rs_Modify.Success ? $"成功新增客戶資料{Rs_Modify.Count}筆" : Rs_Modify.Message; } result = Rs_Modify.Transfor("客戶"); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_Customer> GetCustomer(int?page, string?search) { RS_Customer result = new RS_Customer(); try { var pageIndex = page ?? 1; var customers = this.Daocustomer.GetCustomers(); if (!string.IsNullOrEmpty(search)) { customers = customers.Where(m => m.Name.Contains(search) || m.Company.Contains(search)); } result.Count = customers.Count(); result.PageSize = pageSize; result.CustomerPagedlsit = await customers.ToPagedListAsync(pageIndex, pageSize); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_ModifyResult> DeleteUser(int Id) { RS_ModifyResult result = new RS_ModifyResult("Delete"); try { var ef_find = await this.dbcontext.User.SingleAsync(b => b.Id == Id); this.dbcontext.User.Remove(ef_find); var SaveResult = await this.dbcontext.SaveChangesAsync(); result.Count = SaveResult; result.Success = true; } catch (Exception ex) { result.Message = ex.ToString(); result.Success = false; Nlogger.WriteLog(Nlogger.NType.Error, ex.Message, ex); } return(result); }
public async Task <RS_Object> CreateUser(EF_User DataEntry) { RS_Object result = new RS_Object(); try { var Rs_Modify = await this.CheckUserId(DataEntry.UserId); if (Rs_Modify.Success) { Rs_Modify = await this.Daouser.CreateUser(DataEntry); Rs_Modify.Message = Rs_Modify.Success ? $"成功新增使用者資料{Rs_Modify.Count}筆" : Rs_Modify.Message; } result = Rs_Modify.Transfor("使用者"); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_Object> DeleteCustomer(int Id) { RS_Object result = new RS_Object(); try { var Rs_Modify = await this.CheckCustomerinUser(Id); if (Rs_Modify.Success) { Rs_Modify = await this.Daocustomer.DeleteCustomer(Id); Rs_Modify.Message = Rs_Modify.Success ? $"成功刪除客戶資料{Rs_Modify.Count}筆" : Rs_Modify.Message; } result = Rs_Modify.Transfor("客戶"); Nlogger.WriteLog(Nlogger.NType.Info, Rs_Modify.Message); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_User> GetUser(int?page, string?UserName) { RS_User result = new RS_User(); try { var pageIndex = page ?? 1; var users = this.Daouser.GetUsers(); if (!string.IsNullOrEmpty(UserName)) { users = users.Where(m => m.UserName.Contains(UserName)); } result.Count = users.Count(); result.PageSize = pageSize; result.UserPagedlsit = await users.ToPagedListAsync(pageIndex, pageSize); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_Object> DeleteUser(int userid, int groupid) { RS_Object result = new RS_Object(); try { var Rs_Modify = await this.CheckUserinGroup(userid, groupid); if (Rs_Modify.Success) { Rs_Modify = await this.Daouser.DeleteUser(userid); Rs_Modify.Message = Rs_Modify.Success ? $"成功刪除使用者資料{Rs_Modify.Count}筆" : Rs_Modify.Message; } result = Rs_Modify.Transfor("使用者"); Nlogger.WriteLog(Nlogger.NType.Info, Rs_Modify.Message); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_Object> CreateGroup(EF_Group DataEntry) { RS_Object result = new RS_Object(); try { var Rs_Modify = await this.CheckGroupName(DataEntry.GroupName); if (Rs_Modify.Success) { Rs_Modify = await this.Daogroup.CreateGroup(DataEntry); Rs_Modify.Message = Rs_Modify.Success ? $"成功新增群組資料{Rs_Modify.Count}筆" : Rs_Modify.Message; } result = Rs_Modify.Transfor("群組"); Nlogger.WriteLog(Nlogger.NType.Info, Rs_Modify.Message); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_Group> GetGroup(int?page, string?GroupName) { RS_Group result = new RS_Group(); try { var pageIndex = page ?? 1; var groups = this.Daogroup.GetGroups(); if (!string.IsNullOrEmpty(GroupName)) { groups = groups.Where(m => m.GroupName.Contains(GroupName)); } result.Count = groups.Count(); result.PageSize = pageSize; result.GroupPagedlsit = await groups.ToPagedListAsync(pageIndex, pageSize); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_ModifyResult> UpdateUser(EF_User DataEntry) { RS_ModifyResult result = new RS_ModifyResult("Update"); try { var clone = this.Transfor(DataEntry); var ef_find = await this.dbcontext.User.FirstAsync(b => b.Id == DataEntry.Id); this.dbcontext.Entry(ef_find).CurrentValues.SetValues(clone); this.dbcontext.User.Update(ef_find); var SaveResult = await this.dbcontext.SaveChangesAsync(); result.Count = SaveResult; result.Success = true; } catch (Exception ex) { result.Message = ex.ToString(); result.Success = false; Nlogger.WriteLog(Nlogger.NType.Error, ex.Message, ex); } return(result); }