示例#1
0
        // POST: api/Users
        public async Task <HttpResponseMessage> Post([FromBody] UserViewModel user)
        {
            var userDto = _mapper.Map <UserDto>(user);

            string fileName  = Path.GetRandomFileName() + Constants.PhotoExtension;
            string thumbPath = ImagesProcessor.GetUserAvatar(user.Avatar, fileName, new Size(200, 200));
            string thumbUrl  = Url.Content(thumbPath);

            userDto.Avatar = thumbUrl;

            HttpResponseMessage response;

            try
            {
                await _userService.Register(userDto);

                response = Request.CreateResponse(HttpStatusCode.OK);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                response = Request.CreateResponse(HttpStatusCode.OK, e.Message);
            }

            return(response);
        }
示例#2
0
        public eLearning1918_Start()
        {
            InitializeComponent();

            textBox3.PasswordChar = '*';

            imagini = ImagesProcessor.GetAllImages();

            timer.Interval       = 2000;
            timer.Tick          += new EventHandler(timer_Tick);
            progressBar1.Maximum = imagini.Count() - 1;
            progressBar1.Value   = 0;
            pictureBox1.Image    = imagini.First();

            timer.Start();

            textBox2.Text = "*****@*****.**";
            textBox3.Text = "elev1";
        }
        // POST: api/Photos/?phoneId=*
        public async Task <HttpResponseMessage> AddPhonePhoto(int phoneId, [FromBody] AvatarViewModel photo)
        {
            string fileName  = Path.GetRandomFileName() + Constants.PhotoExtension;
            string thumbPath = ImagesProcessor.GetPhoneImage(photo.Photo, fileName, new Size(193, 410));
            string thumbUrl  = Url.Content(thumbPath);

            HttpResponseMessage response;

            try
            {
                await _photoService.AddPhonePhoto(phoneId, thumbUrl);

                response = Request.CreateResponse(HttpStatusCode.OK, thumbUrl);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message);
            }

            return(response);
        }
        // POST: api/Photos/?userId=*
        public async Task <HttpResponseMessage> SetUserAvatar(string userId, [FromBody] AvatarViewModel avatar)
        {
            string fileName  = Path.GetRandomFileName() + Constants.PhotoExtension;
            string thumbPath = ImagesProcessor.GetUserAvatar(avatar.Photo, fileName, new Size(200, 200));
            string thumbUrl  = Url.Content(thumbPath);

            HttpResponseMessage response;

            try
            {
                await _photoService.SetProfileAvatar(userId, thumbUrl);

                response = Request.CreateResponse(HttpStatusCode.OK);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message);
            }

            return(response);
        }
示例#5
0
        public async Task <HttpResponseMessage> Post([FromBody] PhoneDto phone)
        {
            string fileName  = Path.GetRandomFileName() + Constants.PhotoExtension;
            var    thumbPath = ImagesProcessor.GetPhoneThumbnail(phone.Photo, fileName, new Size(104, 220));

            phone.Photo = Url.Content(thumbPath);

            HttpResponseMessage response;

            try
            {
                await _phonesService.CreatePhone(phone);

                response = Request.CreateResponse(HttpStatusCode.OK, phone.Photo);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message);
            }

            return(response);
        }