public ActionResult Add(Computer model)
        {
            // Only Windows machines require a license.
            if (!string.IsNullOrEmpty(model.LicenseType))
            {
                WindowsLicense license =
                    windowsLicenseDataService.SelectOne(w => !w.Installed && w.LicenseType == model.LicenseType);
                if (license == null)
                {
                    ModelState.AddModelError("LicenseType",
                                             string.Format("Sorry, we are out of {0} licenses.", model.LicenseType));
                    return(View(model));
                }
                model.WindowsLicense = license.Id;
            }

            Volunteer volunteer =
                volunterDataService.SelectOne(v => v.Id == formsAuthenticationService.GetVolunteerID(User));

            model.Active            = true;
            model.ComputerStatus    = "Build";
            model.CreateByVolunteer = volunteer;
            model.CreateDate        = DateTime.Now;
            model.Id                 = Guid.NewGuid();
            model.LifebyteNumber     = computerDataService.NextLbNumber();
            model.LastModByVolunteer = volunteer;
            model.LastModDate        = DateTime.Now;

            computerDataService.Insert(model, model.Id);

            return(RedirectToAction("Edit", "Computer", new { id = model.Id }));
        }
Example #2
0
        /// <summary>
        /// This page allows volunteers to view their profile.
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            Volunteer model = volunteerDataService.SelectOne(v => v.Id == formsAuthenticationService.GetVolunteerID(User));

            // Change password for display purposes.
            model.Password = PasswordChars;

            return(View(model));
        }
Example #3
0
        public ActionResult Add(Recipient model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var volunteer = volunteerDataService.SelectOne(v => v.Id == formsAuthenticationService.GetVolunteerID(User));

            model.Active             = true;
            model.CreateDate         = DateTime.Now;
            model.CreatedByVolunteer = volunteer;
            model.Id = Guid.NewGuid();
            model.LastModifiedByVolunteer = volunteer;
            model.LastModifiedDate        = DateTime.Now;

            recipientDataService.Insert(model, model.Id);

            return(RedirectToAction("Index"));
        }