Пример #1
0
        public async Task UpdateUserBasicInfo(int id, BasicUserDTO userDto)
        {
            try
            {
                var user = await _repo.GetFullUser(id);

                if (user != null)
                {
                    user.Firstname            = userDto.Firstname;
                    user.Lastname             = userDto.Lastname;
                    user.Gender               = userDto.Gender;
                    user.DateOfBirth          = userDto.DateOfBirth.Date;
                    user.IdentificationNumber = userDto.IdentificationNumber;
                    user.CityID               = userDto.CityID;
                }
                foreach (var item in userDto.Phones)
                {
                    var phone = new Phone
                    {
                        Type   = item.Type,
                        Number = item.Number
                    };
                    user.Phones.Add(phone);
                }
                await _repo.Update(id, user);
            }
            catch (Exception e)
            {
                _logger.LogException(e);
                throw e;
            }
        }
Пример #2
0
 public async Task CreateUser(BasicUserDTO userDto)
 {
     try
     {
         var user = new User
         {
             Firstname            = userDto.Firstname,
             Lastname             = userDto.Lastname,
             Gender               = userDto.Gender,
             DateOfBirth          = userDto.DateOfBirth.Date,
             IdentificationNumber = userDto.IdentificationNumber,
             CityID               = userDto.CityID,
             PictureRelativePath  = "",
             Phones               = new List <Phone>(),
             ContactPersons       = new List <RelatedUser>()
         };
         foreach (var item in userDto.Phones)
         {
             var phone = new Phone
             {
                 Type   = item.Type,
                 Number = item.Number
             };
             user.Phones.Add(phone);
         }
         await _repo.Create(user);
     }
     catch (Exception e)
     {
         _logger.LogException(e);
         throw e;
     }
 }
Пример #3
0
        public ActionResult ViewDataPrac()
        {
            ViewBag.Title = "ViewData Practice";

            //ViewBag & ViewData can be used alternatively
            //ViewData is of type 'ViewDataDictionary', data are stored against Key,Value pair format

            //We are adding two parameters to 'ViewData' to pass to View
            ViewData["ID"]      = 1;
            ViewData["Message"] = "Hello World";


            //This will overwrite ViewData 'ID' value
            ViewBag.ID = 2;

            BasicUserDTO dto = new BasicUserDTO();

            dto.UserName = "******";
            dto.Company  = "Testing";

            //Adding as 'Object'
            ViewData["Data"] = dto;

            return(View());
        }
        public ActionResult SaveUser3(String UserName, String Company, String Login, String Password)
        {
            BasicUserDTO user = new BasicUserDTO();

            user.UserName = UserName; //Extract data from FormCollection by providing field 'name'
            user.Company  = Company;
            user.Login    = Login;
            user.Password = Password;

            ViewBag.Msg = String.Format("UserName:'******',Company:'{1}',Login:'******',Password:'******'", user.UserName, user.Company, user.Login, user.Password);
            return(View("Create3"));
        }
        public ActionResult SaveUser2(FormCollection values)
        {
            BasicUserDTO user = new BasicUserDTO();

            user.UserName = values["UserName"]; //Extract data from FormCollection by providing field 'name'
            user.Company  = values["Company"];
            user.Login    = values["Login"];
            user.Password = values["Password"];

            ViewBag.Msg = String.Format("UserName:'******',Company:'{1}',Login:'******',Password:'******'", user.UserName, user.Company, user.Login, user.Password);
            return(View("Create2"));
        }
        public ActionResult SaveUser1()
        {
            BasicUserDTO user = new BasicUserDTO();

            user.UserName = Request.Form["UserName"]; //Extract data from Request.Form by providing field 'name'
            user.Company  = Request["Company"];       //Extract data from Request directly by providing field 'name'
            user.Login    = Request["Login"];
            user.Password = Request.Form["Password"];

            ViewBag.Msg = String.Format("UserName:'******',Company:'{1}',Login:'******',Password:'******'", user.UserName, user.Company, user.Login, user.Password);
            return(View("Create1"));
        }
Пример #7
0
        public BasicUserDTO GetUserByIdBasic(int id)
        {
            var          user         = GetUserById(id);
            BasicUserDTO basicUserDTO = new BasicUserDTO();

            if (user != null)
            {
                basicUserDTO.Id       = user.Id;
                basicUserDTO.UserName = user.First_Name + " " + user.Last_Name;
                basicUserDTO.Avtart   = GetPictureById(user.ProfilePictureId);
            }
            return(basicUserDTO);
        }
Пример #8
0
        public ActionResult ViewBagPrac()
        {
            //ViewBag is of type dynamic.

            //We are adding two parameters to 'ViewBag' to pass to View
            ViewBag.ID      = 1;
            ViewBag.Message = "Hello World";

            BasicUserDTO dto = new BasicUserDTO();

            dto.UserName = "******";
            dto.Company  = "Testing";

            //Adding dto as 'Object'
            ViewBag.Data = dto;

            return(View());
        }
 public ActionResult SaveUser4(BasicUserDTO user)
 {
     ViewBag.Msg = String.Format("UserName:'******',Company:'{1}',Login:'******',Password:'******'", user.UserName, user.Company, user.Login, user.Password);
     return(View("Create4"));
 }