示例#1
0
        public ActionResult Delete(string id)
        {
            var applicant = RavenSession.Load <Applicant>(id);

            RavenSession.Delete(applicant);
            return(RedirectToAction("Index"));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            LogEntry logentry = RavenSession.Load <LogEntry>(id);

            RavenSession.Delete <LogEntry>(logentry);
            return(RedirectToAction("Index"));
        }
示例#3
0
        public ActionResult Delete(int protocolId)
        {
            var plan = RavenSession.Load <Protocol>("protocols/" + protocolId);

            if (plan == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Protocol not found"));
            }

            if (!Ownership.Owns(plan, this))
            {
                return(HttpNotFound());
            }

            if (LoggedInUser.ClinicIds.Contains(plan.ClinicId))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Protocol not found"));
            }

            RavenSession.Delete(plan);
            RavenSession.SaveChanges();

            HighFive("Protocol deleted successfuly");

            return(RedirectToAction("List"));
        }
示例#4
0
        public ActionResult ResetPassword(PasswordResetViewModel postedModel)
        {
            var pr = RavenSession.Query <PasswordReset>().FirstOrDefault(x => x.Token == postedModel.Token);

            if (pr == null || pr.Generated > DateTime.Now.AddHours(2))
            {
                return(View("Reset", new PasswordResetViewModel()));
            }

            if (postedModel.Password != postedModel.ConfirmPassword)
            {
                ModelState.AddModelError("NoMatch", "Passwords must match.");
                return(View("Reset", postedModel));
            }

            var user = RavenSession.Load <User>("users/" + pr.UserId);

            if (user == null)
            {
                ModelState.AddModelError("NoUserMatch", "User account not found.");
                return(View("Reset", postedModel));
            }

            var pw = Hash(postedModel.Password);

            user.Password = pw;

            RavenSession.Delete(pr);
            RavenSession.SaveChanges();

            HighFive("Your password has been changed.");
            return(RedirectToAction("Login"));
        }
示例#5
0
        public ActionResult Delete(string id)
        {
            var jobSearch = RavenSession.Load <JobSearch>(id);

            RavenSession.Delete(jobSearch);
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int id)
        {
            var user = RavenSession.Load <User>("users/" + id);

            if (user == null)
            {
                WarnUser("User could not be found.");
                return(RedirectToAction("Index"));
            }

            if (!Ownership.Owns(user, this))
            {
                return(HttpNotFound());
            }

            var exercises = RavenSession.Query <Exercise>(typeof(ByOwnableAndName).Name).
                            Where(x => !x.Master && (x.AccountId == user.AccountId)).Take(1024);

            foreach (var exercise in exercises)
            {
                RavenSession.Delete(exercise);
            }

            var account = RavenSession.Load <Account>("accounts/" + user.AccountId);

            RavenSession.Delete(account);
            RavenSession.Delete(user);

            RavenSession.SaveChanges();

            this.HighFive("User deleted.");

            return(RedirectToAction("Index"));
        }
示例#7
0
        // DELETE api/assets/5
        public void Delete(int id)
        {
            var owner = ObtainCurrentOwner();
            var asset = GetAsset(id, owner);

            RavenSession.Delete <Asset>(asset);
        }
        public override void Execute()
        {
            foreach (var e in _evaluators)
            {
                if (e.Action == EvaluatorAction.Add)
                {
                    if (_employeeEvaluation.UserName != e.UserName)
                    {
                        var employee = RavenSession
                                       .Query <Employee, EmployeeByUserName_Search>()
                                       .Where(x => x.UserName == e.UserName)
                                       .FirstOrDefault();

                        if (employee != null)
                        {
                            var evId = _employeeEvaluation.Id ?? EmployeeEvaluation.GenerateEvaluationId(_employeeEvaluation.Period, _employeeEvaluation.UserName);
                            ExecuteCommand(new GenerateCalificationCommand(_employeeEvaluation.Period, _employeeEvaluation.UserName, e.UserName, _employeeEvaluation.TemplateId, CalificationType.Evaluator, evId));
                        }
                        else
                        {
                            throw new ApplicationException(string.Format("Error: Evaluador no valido: {0}.", e.UserName));
                        }
                    }
                }
                else
                {
                    var id           = EvaluationCalification.GenerateCalificationId(_employeeEvaluation.Period, _employeeEvaluation.UserName, e.UserName);
                    var calification = RavenSession.Load <EvaluationCalification>(id);
                    if (calification != null)
                    {
                        RavenSession.Delete(calification);
                    }
                }
            }
        }
        private Boolean DeleteProject(Project project, ModelStateDictionary modelState)
        {
            if (project == null)
            {
                modelState.AddModelError("this", "A project must be supplied for deletion");
                return(false);
            }

            var existingProject = RavenSession.Load <Project>(project.Id);

            if (existingProject == null)
            {
                modelState.AddModelError("Id", "Project no longer exists");
                return(false);
            }
            else
            {
                var associatedUserStories = RavenSession.Query <UserStory>()
                                            .Where(us => us.ProjectId == existingProject.Id)
                                            .ToList();

                if (associatedUserStories != null)
                {
                    associatedUserStories.ForEach(RavenSession.Delete);
                }
            }

            RavenSession.Delete(existingProject);
            RavenSession.SaveChanges();

            return(true);
        }
示例#10
0
        public override void Execute()
        {
            var evaluationId              = EmployeeEvaluation.GenerateEvaluationId(_period, _evaluatedEmployee);
            var evaluation                = RavenSession.Load <EmployeeEvaluation>(evaluationId);
            var califications             = RavenSession.Advanced.LoadStartingWith <EvaluationCalification>(evaluationId + "/").ToList();
            var isResponsibleEvalFinished = califications.Any(x => x.Owner == CalificationType.Responsible && x.Finished);
            var isCompanyEvalFinished     = califications.Any(x => x.Owner == CalificationType.Company && x.Finished);
            var isAutoEvalFinished        = califications.Any(x => x.Owner == CalificationType.Auto && x.Finished);
            var isEvaluatorEvalFinished   = califications.Any(x => x.Owner == CalificationType.Evaluator && x.Finished);
            var action = RevertEvaluationActionsHelper.TryParse(_action);

            if (!RevertEvaluationActionsHelper.FindPosibleRevertAction(
                    evaluation.Finished,
                    evaluation.ReadyForDevolution,
                    isCompanyEvalFinished,
                    isResponsibleEvalFinished,
                    isAutoEvalFinished,
                    isEvaluatorEvalFinished,
                    action))
            {
                throw new ApplicationException("Action not allowed");
            }
            var calificationsByType = califications.ToLookup(x => x.Owner);

            switch (action)
            {
            case RevertAction.ReopenForDevolution:
                evaluation.Finished = false;
                break;

            case RevertAction.CancelDevolution:
                evaluation.ReadyForDevolution = false;
                break;

            case RevertAction.ReopenEvalCompany:
                calificationsByType[CalificationType.Company].First().Finished = false;
                break;

            case RevertAction.ReopenEvalResponsible:
                calificationsByType[CalificationType.Responsible].First().Finished = false;
                RavenSession.Delete(calificationsByType[CalificationType.Company].First());
                break;

            case RevertAction.ReopenAutoEvaluation:
                calificationsByType[CalificationType.Auto].First().Finished = false;
                break;

            case RevertAction.ReopenEvalEvaluators:
                foreach (var calification in calificationsByType[CalificationType.Evaluator])
                {
                    calification.Finished = false;
                }
                break;
            }
        }
示例#11
0
        public ActionResult Delete(string id)
        {
            var employee = RavenSession.Load <Employee>(id);

            RavenSession.Delete(employee);
            if (employee == null)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("Index"));
        }
示例#12
0
        public ApiResponse Add(int clinicId)
        {
            var clinic = RavenSession.Load <Clinic>("clinics/" + clinicId);

            RavenSession.Delete(clinic);
            RavenSession.SaveChanges();

            return(new ApiResponse(success: clinic.Name + " deleted")
            {
                Model = clinic
            });
        }
示例#13
0
        public void DeleteOldExercises()
        {
            var exercises = RavenSession.Query <Exercise>()
                            .Where(x => !x.Master).Take(1024).ToList();

            foreach (var exercise in exercises)
            {
                RavenSession.Delete(exercise);
            }

            RavenSession.SaveChanges();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            var book = RavenSession.Load <Book>(id);

            if (book == null)
            {
                return(HttpNotFound("Requested book wasn't found in the system"));
            }
            RavenSession.Delete(book);

            return(Json("Deleted successfully", JsonRequestBehavior.AllowGet));
        }
示例#15
0
 public virtual ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         var item = RavenSession.Load <BlogEntry>(id);
         RavenSession.Delete(item);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#16
0
        public ActionResult Delete(int id, Meeting meeting)
        {
            try
            {
                // TODO: Add delete logic here
                Meeting meetingToDelete = RavenSession.Load <Meeting>(id);
                RavenSession.Delete(meetingToDelete);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#17
0
        public ActionResult Delete(int id)
        {
            var exr = RavenSession.Load <Exercise>("exercises/" + id);

            if (!Ownership.Owns(exr, this))
            {
                return(HttpNotFound());
            }

            RavenSession.Delete(exr);
            RavenSession.SaveChanges();

            HighFive("Exercise deleted.");

            return(RedirectToAction("List"));
        }
示例#18
0
        public ActionResult Delete(int id)
        {
            var section = RavenSession.Load <Section>(id);

            if (section == null)
            {
                return(HttpNotFound("Section does not exist."));
            }

            RavenSession.Delete(section);

            if (Request.IsAjaxRequest())
            {
                return(Json(new { Success = true }));
            }
            return(RedirectToAction("List"));
        }
示例#19
0
        public virtual ActionResult Delete(int id)
        {
            var post = RavenSession.Load <Post>(id);

            if (post == null)
            {
                return(SuccessResponse());
            }

            if (string.IsNullOrEmpty(post.CommentsId) == false)
            {
                RavenSession.Delete(post.CommentsId);
            }

            RavenSession.Delete <Post>(id);

            return(SuccessResponse());
        }
示例#20
0
        public void DeleteOphaned()
        {
            var accountIds = RavenSession.Query <User>().ToList().Select(x => x.AccountId).ToList();

            var exerciseAccountIds = RavenSession.Query <Exercise>().Where(x => !x.Master).Select(x => x.AccountId).Distinct().ToList();

            var no = exerciseAccountIds.Except(accountIds).FirstOrDefault();

            var exercises = RavenSession.Query <Exercise>()
                            .Where(x => !x.Master && x.AccountId == no).Take(1024).ToList();

            foreach (var exercise in exercises)
            {
                RavenSession.Delete(exercise);
            }

            RavenSession.SaveChanges();
        }
        public virtual ActionResult Delete(string id)
        {
            var series = RavenSession.Load <Series>(id);

            if (series == null)
            {
                return(HttpNotFound("Series does not exist."));
            }

            RavenSession.Delete(series);

            OutputCacheManager.RemoveItems(MVC.Series.Name);

            if (Request.IsAjaxRequest())
            {
                return(Json(new { Success = true }));
            }
            return(RedirectToAction("Index"));
        }
 public ActionResult DeleteConfirmed(int id)
 {
     RavenSession.Delete <InsulinDosageModel>(RavenSession.Load <InsulinDosageModel>(id));
     return(RedirectToAction("Index"));
 }
 public ActionResult DeleteConfirmed(int id)
 {
     RavenSession.Delete <DiabetesLogEntryModel>(RavenSession.Load <DiabetesLogEntryModel>(id));
     return(RedirectToAction("Index"));
 }
示例#24
0
        // DELETE api/transactions/ab32ce3232d
        public void Delete(string id)
        {
            var transaction = GetTransaction(id);

            RavenSession.Delete <Transaction>(transaction);
        }