public Role Update(Role t) { if (!IsDuplicate(t)) { if (t.Id <= 0) { throw new ArgumentException("Invalid Role Id"); } Role f = Get(t.Id); if (f == null) { throw new ArgumentNullException($"Role with id {t.Id} does not exist or its deleted"); } f.Name = t.Name; f = DbStore.Save <Role>(f); if (f != null) { roles.Remove(t); roles.Add(f); } return(f); } else { throw new DuplicateItemException("Role already exists"); } }
public LibraryLog Update(LibraryLog t) { LibraryLog f = Get(t.Id); if (f == null) { throw new ArgumentNullException($"Log Details with id {t.Id} does not exist or its deleted"); } libraryLogs.Remove(t); if (t.Id <= 0) { throw new ArgumentException("Invalid Log Details Item Id"); } f.BookNo = t.BookNo; f.BookName = t.BookName; f.MemberName = t.MemberName; f.MobileNo = t.MobileNo; f.Address = t.Address; f.CheckedOutDate = t.CheckedOutDate; f.ReturnedDate = t.ReturnedDate; f = DbStore.Save <LibraryLog>(f); return(f); }
public PettyCash Update(PettyCash t) { if (t.Id <= 0) { throw new ArgumentException("Invalid PettyCash Id"); } PettyCash f = Get(t.Id); if (f == null) { throw new ArgumentNullException($"PettyCash with id {t.Id} does not exist or its deleted"); } f.PaidTo = t.PaidTo; f.Description = t.Description; f.Amount = t.Amount; f.PaymentMode = t.PaymentMode; f.TransactionId = t.TransactionId; f.ReceivedDate = t.ReceivedDate; f.EntryBy = t.EntryBy; f.Status = t.Status; f.AttachedFiles = t.AttachedFiles; f = DbStore.Save <PettyCash>(f); return(f); }
public BookCategory Update(BookCategory t) { BookCategory f = Get(t.Id); if (f == null) { throw new ArgumentNullException($"BookCategory Item with id {t.Id} does not exist or its deleted"); } bookCategory.Remove(t); if (!IsDuplicate(t)) { if (t.Id <= 0) { throw new ArgumentException("Invalid BookCategory Item Id"); } f.CategoryName = t.CategoryName; f.Quantity = t.Quantity; f = DbStore.Save <BookCategory>(f); return(f); } else { bookCategory.Add(f); throw new DuplicateItemException("BookCategory Item already exists"); } }
public Book Update(Book t) { string cName = t.CategoryId.CategoryName; if (t.Id <= 0) { throw new ArgumentException("Invalid Book Item Id"); } Book f = Get(t.Id); if (f == null) { throw new ArgumentNullException($"Book Item with id {t.Id} does not exist or its deleted"); } f.BookNo = t.BookNo; f.BookName = t.BookName; f.AuthorName = t.AuthorName; f.CategoryId = t.CategoryId; f = DbStore.Save <Book>(f); return(f); }
public User Add(User t) { if (!IsDuplicate(t)) { t.Id = 0; t.Password = string.IsNullOrEmpty(t.Password) ? Guid.NewGuid().ToString().Substring(0, 5) : t.Password; var ret = DbStore.Save <User>(t); return(ret); } else { throw new DuplicateItemException("Email already exists"); } }
public User Authenticate(string username, string password) { if (string.IsNullOrEmpty(username)) { throw new ArgumentNullException(nameof(username)); } if (string.IsNullOrEmpty(password)) { throw new ArgumentNullException(nameof(password)); } User user = null; if (!(string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))) { var expression = PredicateBuilder.Create <User>(u => u.UserName == username && u.Password == password && u.IsLocked == false && u.DeletedDate == null); user = userRepository.Get(expression); if (user != null && (!user.Password.Equals(password, StringComparison.Ordinal))) { user = null; } if (user != null) { GenericIdentity identity = new GenericIdentity(user.Id.ToString()); GenericPrincipal principal = new GenericPrincipal(identity, null); Thread.CurrentPrincipal = principal; user.LastLoginTime = DateTime.Now; DbStore.Save <User>(user); } } else { Exception excp = new Exception("Invalid user name / password"); throw excp; } return(user); }
public Member Update(Member t) { if (t.Id <= 0) { throw new ArgumentException("Invalid Member Id"); } Member f = Get(t.Id); if (f == null) { throw new ArgumentNullException($"Member with id {t.Id} does not exist or its deleted"); } if ((f.MemberName != t.MemberName) || (t.Photo is null)) { f.Photo = f.Photo; } else if (f.Photo != t.Photo) { f.Photo = f.FamilyNo + "_" + f.MemberName + ".jpg"; } f.BranchId = t.BranchId; f.FamilyNo = t.FamilyNo; f.MemberTypeId = t.MemberTypeId; f.MemberName = t.MemberName; f.Gender = t.Gender; f.DateofBirth = t.DateofBirth; f.Age = t.Age; f.MobileNo = t.MobileNo; f.AlternateMobileNo = t.AlternateMobileNo; f.Email = t.Email; f.Status = t.Status; f.Address = t.Address; f.BloodGroup = t.BloodGroup; f.MemberTypeId.MemberTypeName = t.MemberTypeId.MemberTypeName; f = DbStore.Save <Member>(f); return(f); }
public LibraryLog Add(LibraryLog t) { if (!IsDuplicate(t)) { t.Id = 0; var ret = DbStore.Save <LibraryLog>(t); if (ret != null) { libraryLogs.Add(ret); } return(ret); } else { throw new DuplicateItemException("Log details already exists"); } }
public BookCategory Add(BookCategory t) { if (!IsDuplicate(t)) { t.Id = 0; var ret = DbStore.Save <BookCategory>(t); if (ret != null) { bookCategory.Add(ret); } return(ret); } else { throw new DuplicateItemException("Book Category already exists"); } }
public Member Add(Member t) { if (!IsDuplicate(t)) { t.Id = 0; var ret = DbStore.Save <Member>(t); if (ret != null) { member.Add(ret); } return(ret); } else { throw new DuplicateItemException("Member already exists"); } }
public Role Add(Role t) { if (!IsDuplicate(t)) { t.Id = 0; var ret = DbStore.Save <Role>(t); if (ret != null) { roles.Add(ret); } return(ret); } else { throw new DuplicateItemException("Role already exists"); } }
public PettyCash Add(PettyCash t) { if (!IsDuplicate(t)) { t.Id = 0; var ret = DbStore.Save <PettyCash>(t); if (ret != null) { pettycashes.Add(ret); } return(ret); } else { throw new DuplicateItemException("Member already exists"); } }
public Branch Add(Branch t) { if (!IsDuplicate(t)) { t.Id = 0; var ret = DbStore.Save <Branch>(t); if (ret != null) { branches.Add(ret); } return(ret); } else { throw new DuplicateItemException("Branchname / Branchcode already exists"); } }
public MemberType Update(MemberType t) { if (t.Id <= 0) { throw new ArgumentException("Invalid Member Type Id"); } MemberType f = Get(t.Id); if (f == null) { throw new ArgumentNullException($"Member Type with id {t.Id} does not exist or its deleted"); } f.MemberTypeName = t.MemberTypeName; f.AgeLimit = t.AgeLimit; f = DbStore.Save <MemberType>(f); return(f); }
public Branch Update(Branch t) { Branch f = Get(t.Id); if (f == null) { throw new ArgumentNullException($"Branch with id {t.Id} does not exist or its deleted"); } branches.Remove(t); if (!IsDuplicate(t)) { if (t.Id <= 0) { throw new ArgumentException("Invalid Branch Id"); } f.BranchName = t.BranchName; f.BranchCode = t.BranchCode; f.Location = t.Location; f.PinCode = t.PinCode; f = DbStore.Save <Branch>(f); if (f != null) { branches.Remove(t); branches.Add(f); } return(f); } else { branches.Add(f); throw new DuplicateItemException("Branchname / Branchcode already exists"); } }
public User Update(User t) { if (t.Id <= 0) { throw new ArgumentException("Invalid User Id"); } User f = Get(t.Id); if (f == null) { throw new ArgumentNullException($"User with id {t.Id} does not exist or its deleted"); } if (f.Email == t.Email) { f.FirstName = t.FirstName; f.MiddleName = t.MiddleName; f.LastName = t.LastName; f.Email = t.Email; f.UserName = t.UserName; f.Mobile = t.Mobile; f.AlternateContact = t.AlternateContact; f.Password = string.IsNullOrEmpty(t.Password) ? f.Password : t.Password; f.ProfilePhoto = string.IsNullOrEmpty(t.ProfilePhoto) ? f.ProfilePhoto : t.ProfilePhoto; f.Roles.Clear(); f = DbStore.Save <User>(f); foreach (Role r in t.Roles) { f.Roles.Add(r); } f = DbStore.Save <User>(f); return(f); } else if (!IsDuplicate(t)) { f.FirstName = t.FirstName; f.MiddleName = t.MiddleName; f.LastName = t.LastName; f.Email = t.Email; f.UserName = t.UserName; f.Mobile = t.Mobile; f.AlternateContact = t.AlternateContact; f.Password = string.IsNullOrEmpty(t.Password) ? f.Password : t.Password; f.ProfilePhoto = string.IsNullOrEmpty(t.ProfilePhoto) ? f.ProfilePhoto : t.ProfilePhoto; f.Roles.Clear(); f = DbStore.Save <User>(f); foreach (Role r in t.Roles) { f.Roles.Add(r); } f = DbStore.Save <User>(f); return(f); } else { throw new DuplicateItemException("Email already exists"); } }