Esempio n. 1
0
        public async Task <ActionResult> Create(HortaBindingModel horta)
        {
            var model = new HortaDataModel()
            {
                Titulo    = horta.Titulo,
                Descricao = horta.Descricao,
                PerfilId  = horta.PerfilId
            };

            try
            {
                HttpFileCollectionBase files = Request.Files;

                int fileCount = files.Count;

                await _blobHelper.SetupCloudBlob(connectionString);

                var blob = _blobHelper._blobCointainer.GetBlockBlobReference(_blobHelper.GetRandomBlobName(files[0].FileName));

                await blob.UploadFromStreamAsync(files[0].InputStream);

                model.Foto = blob.StorageUri.PrimaryUri.ToString();

                await _clientHelper.PostHortaAsync(model);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 2
0
        // GET: Horta/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            var horta = await _clientHelper.GetHortaAsync(id);

            var perfis = await _clientHelper.GetPerfilsAsync();

            var perfil = await _clientHelper.GetPerfilAsync(horta.PerfilId);

            var model = new HortaBindingModel()
            {
                Titulo     = horta.Titulo,
                Descricao  = horta.Descricao,
                Foto       = horta.Foto,
                Id         = id,
                PerfilId   = horta.PerfilId,
                PerfilNome = perfil.Nome
            };

            foreach (var item in perfis)
            {
                var SelectItem = new SelectListItem()
                {
                    Value = item.Id.ToString(),
                    Text  = item.Nome
                };
                model.Perfis.Add(SelectItem);
            }

            return(View(model));
        }
Esempio n. 3
0
        // GET: Horta/Create
        public async Task <ActionResult> Create()
        {
            var perfis = await _clientHelper.GetPerfilsAsync();

            var model = new HortaBindingModel();

            foreach (var item in perfis)
            {
                var SelectItem = new SelectListItem()
                {
                    Value = item.Id.ToString(),
                    Text  = item.Nome
                };
                model.Perfis.Add(SelectItem);
            }

            return(View(model));
        }