Exemple #1
0
        public void UpdateReferrals(VEPReferalsViewModel vmodel)
        {
            var OldObj = (from c in dbContext.VEP_Referals
                          where c.CaseId == (vmodel.Caseid)
                          select c).FirstOrDefault();

            if (OldObj != null)
            {
                OldObj.CreateDate = vmodel.CreateDate;
                OldObj.Createdby  = (from r in dbContext.Users
                                     where r.User_Name == vmodel.CreatedByString
                                     select r.User_Id).FirstOrDefault();
                OldObj.FromDepartment = Convert.ToInt32(vmodel.FromDepartment);
                OldObj.ToDepartment   = Convert.ToInt32(vmodel.ToDepartment);
                OldObj.Notes          = vmodel.Notes;
                dbContext.SaveChanges();
            }
            else
            {
                var NewObj = new VEP_Referals();
                NewObj.CreateDate     = vmodel.CreateDate;
                NewObj.Createdby      = vmodel.Createdby;
                NewObj.FromDepartment = Convert.ToInt32(vmodel.FromDepartment);
                NewObj.ToDepartment   = Convert.ToInt32(vmodel.ToDepartment);
                NewObj.Notes          = vmodel.Notes;
                NewObj.CaseId         = vmodel.Caseid;
                //NewObj.CaseId = Convert.ToInt32(Session["CaseID"]);
                dbContext.VEP_Referals.Add(NewObj);
                dbContext.SaveChanges();
            }
        }
Exemple #2
0
        public VEP_Referals CreateReferrals(VEP_Referals model)
        {
            var dbContext = new SDIIS_DatabaseEntities();

            try
            {
                VEP_Referals referalTable = new VEP_Referals();

                referalTable.CaseId         = model.CaseId;
                referalTable.FromDepartment = 1;
                referalTable.ToDepartment   = Convert.ToInt32(model.ToDepartment);
                referalTable.Notes          = model.Notes;
                referalTable.Createdby      = model.Createdby;
                referalTable.CreateDate     = DateTime.Now;

                dbContext.VEP_Referals.Add(referalTable);
                dbContext.SaveChanges();

                return(model);
            }
            catch (Exception ex)
            {
                var Test = ex.Message;
                return(null);
            }
        }