コード例 #1
0
        //[Route("Invitation/{idV}/{idA}")]
        public ActionResult InvitCreate(string idV, int idA)
        {
            //try
            //{
            Invitation        I  = new Invitation();
            InvitationService IS = new InvitationService();


            I.Status      = Domain.Enums.InvitationStatus.Unanswered;
            I.ActionId    = idA;
            I.VolunteerId = idV;
            if (IS.NumberOfInvitesIfExist(idA, idV) == 0)
            {
                invtService.Add(I);
            }

            try
            {
                invtService.Commit();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                foreach (var entityValidationErrors in ex.EntityValidationErrors)
                {
                    foreach (var validationError in entityValidationErrors.ValidationErrors)
                    {
                        Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                    }
                }

                //           }
                //           catch
                //           {
                //return View();
                //           }
            }
            return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()));
        }