public async Task <IActionResult> create(Logica.Models.BindingModels.ProjectsCreateBindingModel model)
        {
            if (ModelState.IsValid)
            {
                IdentityUser user = await _userManager.FindByIdAsync(User.FindFirst(ClaimTypes.NameIdentifier).Value);

                Logica.BL.Tenants tenants = new Logica.BL.Tenants();
                var tenant = tenants.GetTenants(user.Id).FirstOrDefault();

                Logica.BL.Projects projects = new Logica.BL.Projects();
                projects.CreatedProjects(model.Title, model.Details, model.ExpectedCompletionDate, tenant.Id);

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Example #2
0
        public async Task <ActionResult> ProjectsCreate(Logica.Models.BindingModels.ProjectsCreateBindingModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //Recupero el Usuario en sesion
                    ApplicationUser user = await UserManager.FindByNameAsync(User.Identity.Name);

                    //Consulta la organizacion del usuario que esta ingresando al sistema
                    Logica.BL.Tenants tenants = new Logica.BL.Tenants();
                    var tenant = tenants.GetTenants(user.Id).FirstOrDefault();;

                    Logica.BL.Projects projects = new Logica.BL.Projects();
                    projects.CreateProjects(model.Title,
                                            model.Details,
                                            model.ExpectedCompletionDate,
                                            tenant.Id);
                }
                else
                {
                    return(Json(new Logica.Models.ViewModels.ResponseViewModel
                    {
                        IsSuccessful = false,
                        Errors = ModelState.Values.SelectMany(x => x.Errors).Select(e => e.ErrorMessage).ToList()
                    }, JsonRequestBehavior.AllowGet));
                }

                return(Json(new
                {
                    IsSuccessful = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new Logica.Models.ViewModels.ResponseViewModel
                {
                    IsSuccessful = false,
                    Errors = new List <string> {
                        ex.Message
                    }
                }, JsonRequestBehavior.AllowGet));
            }
        }
Example #3
0
        public async Task <ActionResult> Create(Logica.Models.BindingModels.ProjectsCreateBindingModel model)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser user = await UserManager.FindByNameAsync(User.Identity.Name);

                Logica.BL.Tenants tenants = new Logica.BL.Tenants();
                var tenant = tenants.GetTenants(user.Id).FirstOrDefault();

                Logica.BL.Projects projects = new Logica.BL.Projects();
                projects.CreateProjects(model.Title,
                                        model.Details,
                                        model.ExpectedCompletionDate,
                                        tenant.Id);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
        public async Task <ActionResult> ProjectsCreate(Logica.Models.BindingModels.ProjectsCreateBindingModel model)
        {
            if (ModelState.IsValid)
            {
                //Recupero el Usuario en sesion
                ApplicationUser user = await UserManager.FindByNameAsync(User.Identity.Name);

                //Consulta la organizacion del usuario que esta ingresando al sistema
                Logica.BL.Tenants tenants = new Logica.BL.Tenants();
                var tenant = tenants.GetTenants(user.Id).FirstOrDefault();;

                Logica.BL.Projects projects = new Logica.BL.Projects();
                projects.CreateProjects(model.Title,
                                        model.Details,
                                        model.ExpectedCompletionDate,
                                        tenant.Id);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }