public bool AddPresentationConditionToCase(int CaseId, List <int> conditionsIds)
        {
            var dbContext = new SDIIS_DatabaseEntities();

            try
            {
                var conditionsToEdit = dbContext.VEP_VictimsConditions.Where(x => x.Caseid.Equals(CaseId));

                dbContext.VEP_VictimsConditions.RemoveRange(conditionsToEdit);
                dbContext.SaveChanges();

                foreach (var roleId in conditionsIds)
                {
                    var newCondition = new VEP_VictimsConditions()
                    {
                        Caseid = CaseId,
                        PresentationConditionID = roleId
                    };

                    dbContext.VEP_VictimsConditions.Add(newCondition);
                    dbContext.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                var Test = ex.Message;
                return(false);
            }
        }
        public int Create(int selected_ConditionId, int CaseId)
        {
            var dbContext = new SDIIS_DatabaseEntities();

            try
            {
                var victimRecord = new VEP_VictimsConditions();

                victimRecord.Caseid = CaseId;
                victimRecord.PresentationConditionID = selected_ConditionId;

                dbContext.VEP_VictimsConditions.Add(victimRecord);
                dbContext.SaveChanges();

                return(victimRecord.Id);
            }
            catch (Exception ex)
            {
                var Test = ex.Message;
                return(-1);
            }
        }
Beispiel #3
0
        public VEP_VictimsConditions UpdateVictimCondition(VictimRecord Obj, int Id)
        {
            int CheckIfExistVEP_VictimsConditions = (from x in dbContext.VEP_VictimsConditions
                                                     where x.Caseid == Id
                                                     select x.Id).FirstOrDefault();

            if (CheckIfExistVEP_VictimsConditions == 0)
            {
                VEP_VictimsConditions VCModel = new VEP_VictimsConditions();
                VCModel.Caseid = Id;
                //VCModel.Angry = Obj.VictimConditions.Angry;
                //VCModel.ExecivelyAlert = Obj.VictimConditions.ExecivelyAlert;
                //VCModel.FullyMobile = Obj.VictimConditions.FullyMobile;
                //VCModel.LookAfraid = Obj.VictimConditions.LookAfraid;
                //VCModel.Panic = Obj.VictimConditions.Panic;
                //VCModel.VictimsConditionsID = 1;
                dbContext.VEP_VictimsConditions.Add(VCModel);
                dbContext.SaveChanges();
                return(VCModel);
            }
            else
            {
                VEP_VictimsConditions VCModel = (from k in dbContext.VEP_VictimsConditions
                                                 where k.Caseid == Id
                                                 select k).FirstOrDefault();
                VCModel.Caseid = Id;
                //VCModel.Angry = Obj.VictimConditions.Angry;
                //VCModel.ExecivelyAlert = Obj.VictimConditions.ExecivelyAlert;
                //VCModel.FullyMobile = Obj.VictimConditions.FullyMobile;
                //VCModel.LookAfraid = Obj.VictimConditions.LookAfraid;
                //VCModel.Panic = Obj.VictimConditions.Panic;
                //VCModel.VictimsConditionsID = 1;
                dbContext.SaveChanges();
                return(VCModel);
            }
        }