예제 #1
0
 public int Save(User entity)
 {
     ValidationResultInfo vri = Validate(entity);
     if (!vri.IsValid)
     {
         throw new DomainValidationException(vri, "Product Details provided not valid");
     }
     DateTime date = DateTime.Now;
     tblUser tbl = _ctx.tblUser.FirstOrDefault(s => s.Id == entity.Id);
     if (tbl == null)
     {
         tbl = new tblUser();
         tbl.IM_DateCreated = date;
         tbl.IM_IsActive = true;
         tbl.HasChangePassword = false;
         tbl.LastLogin = date;
         _ctx.tblUser.Add(tbl);
     }
     tbl.IM_DateUpdated = date;
     tbl.Username = entity.Username;
     tbl.FullName = entity.FullName;
     tbl.Email = entity.Email;
     tbl.Password = entity.Password;
     tbl.PhoneNo = entity.PhoneNo;
     _ctx.SaveChanges();
     _cacheProvider.Put(_cacheListKey, _ctx.tblUser.Where(x => x.IM_IsActive).Select(s => s.Id).ToList());
     _cacheProvider.Remove(string.Format(_cacheKey, tbl.Id));
     return tbl.Id;
 }
예제 #2
0
 private User Map(tblUser tbl)
 {
     return new User
                {
                    Id = tbl.Id,
                    IsActive=tbl.IM_IsActive,
                    DateCreated=tbl.IM_DateCreated,
                    DateUpdated=tbl.IM_DateUpdated,
                    Email=tbl.Email,
                    FullName=tbl.FullName,
                    HasChangePassword=tbl.HasChangePassword,
                    LastLogin=tbl.LastLogin,
                    Password=tbl.Password,
                    PhoneNo=tbl.PhoneNo,
                    Username=tbl.Username,
                  
                    
                    
                };
 }