/// <summary> /// function insert and update and delete category /// </summary> /// <param name="ctgr"></param> model category /// <param name="action_status"></param> status: (add; edit; insert) /// <returns></returns> public bool Add_and_Edit_Category(category ctgr, int action_status) { bool check = false; try { if (Util.Cnv_Int(ctgr.id.ToString()) > 0) { category data_edit = new category(); data_edit = Get_Category(ctgr.id); if (action_status == Variable.action_status.is_update) // update data { data_edit.Name = ctgr.Name; data_edit.Note = ctgr.Note; data_edit.UpdatedAt = DateTime.Now; } else if (action_status == Variable.action_status.is_delete) // delete data { data_edit.Status = ctgr.Status; } } else { _db.category.Add(ctgr); // add data } _db.SaveChanges(); check = true; } catch (Exception) { return(check); } return(check); }
public bool Add_and_Edit_User(user ctgr, int action_status) { bool check = false; try { if (Util.Cnv_Int(ctgr.id.ToString()) > 0) { user data_edit = new user(); data_edit = Get_User(ctgr.id); if (action_status == Variable.action_status.is_update) { // update data data_edit.FullName = ctgr.FullName; data_edit.Note = ctgr.Note; data_edit.UpdatedAt = DateTime.Now; data_edit.Sex = ctgr.Sex; data_edit.Type = ctgr.Type; data_edit.PhoneNumber = ctgr.PhoneNumber; data_edit.IdCard = ctgr.IdCard; data_edit.BirthDay = ctgr.BirthDay; data_edit.Address = ctgr.Address; if (ctgr.PassWord != "" && ctgr.PassWord != null) { data_edit.PassWord = ctgr.PassWord; } } else if (action_status == Variable.action_status.is_delete) // delete data { data_edit.Status = ctgr.Status; } } else { _DB.users.Add(ctgr); // add data } _DB.SaveChanges(); check = true; } catch (Exception) { return(check); } return(check); }
/// <summary> /// function insert and update and delete User /// </summary> /// <param name="ctgr"></param> model User /// <param name="action_status"></param> status: (add; edit; insert) /// <returns></returns> public bool Delete_Info_Customer(customer customer, user user) { try { (from f in _db.friends where f.CustomerId.Equals(customer.id) select f) .ToList() .ForEach(i => i.Status = false); (from f in _db.friends where f.CustomerId.Equals(customer.id) select f) .ToList() .ForEach(i => i.UpdatedBy = user.id); (from f in _db.friends where f.CustomerId.Equals(customer.id) select f) .ToList() .ForEach(i => i.UpdatedAt = DateTime.Now); (from f in _db.historyPaids where f.CustomerId.Equals(customer.id) select f) .ToList() .ForEach(i => i.Status = false); (from f in _db.historyPaids where f.CustomerId.Equals(customer.id) select f) .ToList() .ForEach(i => i.UpdatedBy = user.id); (from f in _db.historyPaids where f.CustomerId.Equals(customer.id) select f) .ToList() .ForEach(i => i.UpdatedAt = DateTime.Now); _db.SaveChanges(); } catch (Exception) { return(false); } return(true); }
public bool Add_Paid_Money(historyPaid hisPaid, int action_status, user user) { bool check = false; try { hisPaid.CreatedBy = user.id; hisPaid.UpdatedBy = user.id; _db.historyPaids.Add(hisPaid); _db.SaveChanges(); check = true; } catch (Exception) { return(check); } return(check); }
/// <summary> /// function insert and update and delete User /// </summary> /// <param name="ctgr"></param> model User /// <param name="action_status"></param> status: (add; edit; insert) /// <returns></returns> public bool Add_and_Edit_Friend(friend ctgr, int action_status) { bool check = false; try { if (Util.Cnv_Int(ctgr.id.ToString()) > 0) { friend data_edit = new friend(); data_edit = Get_Friend(ctgr.id); if (action_status == Variable.action_status.is_update) { // update data data_edit.FullName = ctgr.FullName; data_edit.PhoneNumber = ctgr.PhoneNumber; data_edit.Note = ctgr.Note; data_edit.UpdatedAt = DateTime.Now; data_edit.UpdatedBy = ctgr.UpdatedBy; data_edit.Relationship = ctgr.Relationship; } else if (action_status == Variable.action_status.is_delete) // delete data { data_edit.Status = ctgr.Status; } } else { _db.friends.Add(ctgr); // add data } _db.SaveChanges(); check = true; } catch (Exception) { return(check); } return(check); }
public bool Add_and_Edit_HistoryInterest(historyInterestRate historyInterest, int action_status, user user) { bool check = false; try { historyInterest.CreatedBy = user.id; historyInterest.UpdatedBy = user.id; historyInterest.InterestRateId = 1; historyInterest.Status = true; historyInterest.CreatedAt = DateTime.Now; historyInterest.UpdatedAt = DateTime.Now; changeStatusHistoryInterest(); _db.historyInterestRates.Add(historyInterest); _db.SaveChanges(); check = true; } catch (Exception) { return(check); } return(check); }