コード例 #1
0
        public bool UpdateUser(UserDetailsBO userDetailsBO)
        {
            UserInfoRepository repo = new UserInfoRepository();
            bool result             = repo.Update(new userinfo
            {
                firstname = userDetailsBO.FirstName,
                lastname  = userDetailsBO.LastName,
                password  = userDetailsBO.Password,
                userid    = userDetailsBO.UserId, userkey = userDetailsBO.UserKey
            });

            if (userDetailsBO.Address != null)
            {
                var custaddress = new Data.addressmaster()
                {
                    addrkey  = userDetailsBO.Address.AddrKey,
                    address1 = userDetailsBO.Address.Address1,
                    address2 = userDetailsBO.Address.Address2,
                    city     = userDetailsBO.Address.City,
                    state    = userDetailsBO.Address.State,
                    country  = userDetailsBO.Address.Country,
                    zipcode  = userDetailsBO.Address.Zip,
                    email    = userDetailsBO.Address.Email,
                    fax      = userDetailsBO.Address.Fax,
                    phone    = userDetailsBO.Address.Phone,
                    website  = userDetailsBO.Address.Website,
                    addrname = userDetailsBO.UserId
                };
                bool updated = new AddressMasterRepository().Update(custaddress);
            }
            return(result);
        }
コード例 #2
0
 public void SaveUserDetails(UserDetailsBO userDetails)
 {
     using (var db = new UCM_MAINEntities())
     {
         var user = db.UserDetails.Where(p => p.UserId == userDetails.UserId).FirstOrDefault();
         if (null != user)
         {                //Update scenario
             user.FirstName   = userDetails.FirstName;
             user.EmailId     = userDetails.EmailId;
             user.LastName    = userDetails.LastName;
             user.Status      = userDetails.Status;
             user.PhoneNumber = userDetails.PhoneNumber;
         }
         else
         {                //Add new record
             db.UserDetails.Add(new UserDetail
             {
                 EmailId     = userDetails.EmailId,
                 FirstName   = userDetails.FirstName,
                 LastName    = userDetails.LastName,
                 PhoneNumber = userDetails.PhoneNumber,
                 Status      = userDetails.Status,
                 UserId      = userDetails.UserId
             });
         }
         db.SaveChanges();
     }
 }
コード例 #3
0
        public bool AddUser(UserDetailsBO userDetailsBO)
        {
            UserInfoRepository      repo        = new UserInfoRepository();
            AddressMasterRepository addressRepo = new AddressMasterRepository();
            List <company>          usercompany = new List <company>();
            Guid Addresskey = Guid.Empty;

            if (userDetailsBO.Address != null)
            {
                Addresskey = addressRepo.Add(new addressmaster
                {
                    addrname = userDetailsBO.FirstName,
                    addrkey  = Guid.NewGuid(),
                    address1 = userDetailsBO.Address.Address1,
                    address2 = userDetailsBO.Address.Address2,
                    city     = userDetailsBO.Address.City,
                    state    = userDetailsBO.Address.State,
                    zipcode  = userDetailsBO.Address.Zip,
                    phone    = userDetailsBO.Address.Phone,
                    fax      = userDetailsBO.Address.Fax,
                    email    = userDetailsBO.Address.Email,
                });
            }
            if (userDetailsBO.CompanyKey != null)
            {
                CompanyRepository companyRepo = new CompanyRepository();
                var result = companyRepo.GetbyId(userDetailsBO.CompanyKey.Value);
                if (result != null)
                {
                    usercompany.Add(result);
                }
            }
            userinfo userinfo = new userinfo
            {
                userid     = userDetailsBO.UserId,
                firstname  = userDetailsBO.FirstName,
                lastname   = userDetailsBO.LastName,
                password   = userDetailsBO.Password,
                addrkey    = Addresskey,
                createdate = DateTime.Now,
                status     = 1
            };

            var usrKey = repo.Add(userinfo);

            if (usrKey != null || usrKey != Guid.Empty)
            {
                return(true);
            }
            return(false);
        }
コード例 #4
0
        public HttpResponseMessage Put([FromBody] UserDetailsBO user)
        {
            UserOperationsBL bll    = new UserOperationsBL();
            bool             result = bll.UpdateUser(user);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.OK,
                                              result, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "User update failed!"));
            }
        }
コード例 #5
0
        public ActionResult UpdateUserDetails(UserDetailsBO user)
        {
            CRUDUserRequest userResponse = new CRUDUserRequest
            {
                EmailId     = user.EmailId,
                FirstName   = user.FirstName,
                LastName    = user.LastName,
                PhoneNumber = user.PhoneNumber,
                Status      = user.Status,
                UserId      = user.UserId
            };

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Constants.ProfileApiUrl);
                //HTTP Post

                var responseTask = client.PostAsJsonAsync("profiles/saveUser", userResponse);
                responseTask.Wait();
                var result = responseTask.Result;
            }
            return(RedirectToAction("GetUsers"));
        }
コード例 #6
0
        public UserDetailsBO GetUserById(string userKey)
        {
            UserInfoRepository repo = new UserInfoRepository();
            var userinfo            = repo.GetbyId(Guid.Parse(userKey));

            if (userinfo != null)
            {
                UserDetailsBO bo = new UserDetailsBO();
                bo.FirstName = userinfo.firstname;
                bo.LastName  = userinfo.lastname;
                bo.UserKey   = userinfo.userkey;
                bo.UserId    = userinfo.userid;
                bo.Password  = userinfo.password;
                if (userinfo.addressmaster != null)
                {
                    bo.Address = new AddressBO
                    {
                        AddrKey  = userinfo.addressmaster.addrkey,
                        Phone    = userinfo.addressmaster.phone,
                        Email    = userinfo.addressmaster.email,
                        Fax      = userinfo.addressmaster.fax,
                        Address1 = userinfo.addressmaster.address1,
                        Address2 = userinfo.addressmaster.address2,
                        City     = userinfo.addressmaster.city,
                        State    = userinfo.addressmaster.state,
                        Zip      = userinfo.addressmaster.zipcode,
                        Country  = userinfo.addressmaster.country,
                        Website  = userinfo.addressmaster.website
                    };
                }
                return(bo);
            }
            else
            {
                return(null);
            }
        }
コード例 #7
0
        public IHttpActionResult SaveUserDetails([FromBody] CRUDUserRequest request)

        {
            try
            {
                UserDetailsBO userBO = new UserDetailsBO
                {
                    EmailId     = request.EmailId,
                    FirstName   = request.FirstName,
                    LastName    = request.LastName,
                    PhoneNumber = request.PhoneNumber,
                    Status      = request.Status,
                    UserId      = request.UserId
                };
                _profileService.SaveUserDetails(userBO);
            }
            catch (Exception ex)
            {
                return(InternalServerError());
            }


            return(Ok());
        }
コード例 #8
0
        public List <UserDetailsBO> GetAllUser()
        {
            UserInfoRepository   repo = new UserInfoRepository();
            List <UserDetailsBO> list = new List <UserDetailsBO>();

            var userinfo = repo.GetAll();

            if (userinfo != null)
            {
                foreach (var user in userinfo)
                {
                    UserDetailsBO bo = new UserDetailsBO();
                    bo.FirstName = user.firstname;
                    bo.LastName  = user.lastname;
                    bo.UserKey   = user.userkey;
                    bo.UserId    = user.userid;
                    bo.Password  = user.password;

                    if (user.addressmaster != null)
                    {
                        bo.Address = new AddressBO
                        {
                            Phone    = user.addressmaster.phone,
                            Email    = user.addressmaster.email,
                            Fax      = user.addressmaster.fax,
                            Address1 = user.addressmaster.address1,
                            Address2 = user.addressmaster.address2,
                            City     = user.addressmaster.city,
                            State    = user.addressmaster.state,
                            Zip      = user.addressmaster.zipcode,
                            Country  = user.addressmaster.country,
                            Website  = user.addressmaster.website
                        };
                    }
                    list.Add(bo);
                }
                //    UserDetailsBO bo = new UserDetailsBO();
                //bo.FirstName = userinfo.firstname;
                //bo.LastName = userinfo.lastname;
                //bo.UserKey = userinfo.userkey;
                //bo.UserId = userinfo.userid;
                //if (userinfo.addressmaster != null)
                //{
                //    bo.address = new AddressBO
                //    {
                //        Phone = userinfo.addressmaster.phone,
                //        Email = userinfo.addressmaster.email,
                //        Fax = userinfo.addressmaster.fax,
                //        Address1 = userinfo.addressmaster.address1,
                //        Address2 = userinfo.addressmaster.address2,
                //        City = userinfo.addressmaster.city,
                //        State = userinfo.addressmaster.state
                //    };
                //}
                return(list);
            }
            else
            {
                return(null);
            }
        }
コード例 #9
0
 public void SaveUserDetails(UserDetailsBO userDetails)
 {
     _profileOperations.SaveUserDetails(userDetails);
 }