public IList <IUserDTO> GetAllUser() { IList <IUserDTO> usersDTOList = new List <IUserDTO>(); using (CasinoCustomerEntities context = new CasinoCustomerEntities()) { var usersEntity = context.Users.ToList(); foreach (var user in usersEntity) { IUserDTO usersDTO = (IUserDTO)DTOFactory.Instance.Create(DTOType.UserDTO); EntityConverter.FillDTOFromEntity(user, usersDTO); usersDTOList.Add(usersDTO); } context.SaveChanges(); } return(usersDTOList); }
public IUserDTO UpdateUser(int persondid, int amt) { IUserDTO usersDTO1 = null; User updateUser = new User(); using (CasinoCustomerEntities context = new CasinoCustomerEntities()) { User customer = context.Users.Where(item => item.PersonID == persondid).FirstOrDefault(); if (customer != null) { customer.Balance += amt; } if (context.SaveChanges() > 0) { EntityConverter.FillDTOFromEntity(customer, usersDTO1); } } return(usersDTO1); }
public IUserDTO GetUserById(string id) { IUserDTO usersDTO = (IUserDTO)DTOFactory.Instance.Create(DTOType.UserDTO); using (CasinoCustomerEntities context = new CasinoCustomerEntities()) { var usersEntity = context.Users.ToList(); foreach (var user in usersEntity) { if (user.Emailid == id) { //IUserDTO usersDTO = (IUserDTO)DTOFactory.Instance.Create(DTOType.UserDTO); EntityConverter.FillDTOFromEntity(user, usersDTO); } } context.SaveChanges(); } return(usersDTO); }
public IUserDTO UpdateBalanceAmount(string emailid, int amt) { IUserDTO usersDTO1 = (IUserDTO)DTOFactory.Instance.Create(DTOType.UserDTO); User updateUser = new User(); using (CasinoCustomerEntities context = new CasinoCustomerEntities()) { User customer = context.Users.Where(item => item.Emailid == emailid).FirstOrDefault(); if (customer != null) { customer.Balance += amt; customer.Blocked = 0; } if (context.SaveChanges() > 0) { EntityConverter.FillDTOFromEntity(customer, usersDTO1); } } return(usersDTO1); }
public IUserDTO CreateUser(IUserDTO usersDTO) { IUserDTO usersDTO1 = (IUserDTO)DTOFactory.Instance.Create(DTOType.UserDTO); using (CasinoCustomerEntities context = new CasinoCustomerEntities()) { User user = new User(); EntityConverter.FillEntityFromDTO(usersDTO, user); //user.IsActive = true; context.Users.Add(user); if (context.SaveChanges() > 0) { EntityConverter.FillDTOFromEntity(user, usersDTO1); } //context.SaveChanges(); } // try //{ // using (CustomerPortalEntities context = new CustomerPortalEntities()) // { // CustomerTable customer = new CustomerTable(); // custDTO.BlockBalance = 0; // custDTO.AccountBalance = 500; // EntityDataModel.EntityConverter.FillEntityFromDTO(custDTO, customer); // context.CustomerTables.Add(customer); // if (context.SaveChanges() > 0) // { // custDTO.CustomerId = customer.CustomerId; // createCustomerRetval = custDTO; // } // } return(usersDTO1); }