Ejemplo n.º 1
0
        public ActionResult CreateAppraisalQuestion([Bind(Include = "AppraisalId, AppraisalQuestionGroupId, AppraisalQuestionTypeId, Question, QuestionNumber")] AppraisalQuestion newQuestion)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    entities.AppraisalQuestions.Add(newQuestion);
                    entities.SaveChanges();
                    return(RedirectToAction("ListAppraisalQuestions", "Administration", new { id = newQuestion.AppraisalId }));
                }
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("SAVE_ERR", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            return(View(newQuestion));
        }
        public ActionResult IdentifyPartners(ICollection <int> AssociateWorkId, ICollection <int> EmployeeId, ICollection <string> ClientName, ICollection <string> ClientMatter, ICollection <string> MatterName, ICollection <float> Hours, ICollection <int> PartnerEmployeeId)
        {
            /*  WARNING - This is a good way to check for errors in the ModelState
             * var errors = ModelState.Values.SelectMany(v => v.Errors);
             * foreach (var error in errors)
             * {
             *  string poop = error.ToString();
             * }*/

            try
            {
                if (ModelState.IsValid)
                {
                    int count = 0;
                    foreach (AssociateWork assWork in entities.AssociateWorks)
                    {
                        if (assWork.AssociateWorkId == AssociateWorkId.ElementAt(count))
                        {
                            assWork.PartnerEmployeeId = PartnerEmployeeId.ElementAt(count);
                            count++;
                            entities.SaveChanges();
                        }
                    }

                    return(RedirectToAction("Index", "Home"));
                }
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("SAVE_ERR", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            catch (Exception ex)
            {
                string poop = ex.Message;
            }
            return(RedirectToAction("Error", "Home"));  // WARNING = This isn't right at all, but at least I'll know we err'd
                                                        // if we're here, the DB did not update.
        }