示例#1
0
        public IResultadoOperaciones <Person> Create([FromForm] Person Person)
        {
            foreach (var item in HttpContext.Request.Form.Files)
            {
                var PathPhoto = Person.passport + Path.GetExtension(item.FileName);
                Person.photo = PathPhoto;
                IResultadoOperaciones <Person> result = _PersonServices.Create(Person);

                if (result == null)
                {
                    return(BasicOperationResult <Person> .Fail(result.Message));
                }
                var filePath = "Documentos";

                if (item.Length > 0)
                {
                    using (var stream = new FileStream(Path.Combine(Environment.CurrentDirectory, filePath, PathPhoto), FileMode.Create))
                    {
                        item.CopyToAsync(stream);
                        stream.Close();
                    }
                }
                return(result);
            }
            return(BasicOperationResult <Person> .Fail("No estan todos los datos disponibles"));
        }
        public ActionResult Create([Bind(Include = "Id, Birthday, Name, LastName, Email, Role")] PersonViewModel model)
        {
            try
            {
                var ps = new PersonServices();

                ps.Create(model);

                return(RedirectToAction("Index"));
            }
            catch (DbEntityValidationException e)
            {
                return(View(model));
            }
        }