Exemplo n.º 1
0
        public VEP_Services CreateService(VEP_Services model)
        {
            var dbContext = new SDIIS_DatabaseEntities();

            try
            {
                VEP_Services servicesTable = new VEP_Services();

                servicesTable.CaseId = model.CaseId;
                //servicesTable.PersonId = model.clientID;
                servicesTable.ServiceTypeId = model.ServiceTypeId;
                servicesTable.ServiceNotes  = model.ServiceNotes;
                servicesTable.DateCreated   = DateTime.Now;
                servicesTable.isActive      = 1;

                dbContext.VEP_Services.Add(servicesTable);
                dbContext.SaveChanges();

                return(model);
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                var Test = dbEx.Message;
                return(null);
            }
        }
Exemplo n.º 2
0
        public void CreateService(VEPServicesViewModel model)
        {
            var dbContext = new SDIIS_DatabaseEntities();

            try
            {
                VEP_Services servicesTable = new VEP_Services();

                servicesTable.CaseId    = model.Caseid;
                servicesTable.ServiceId = model.Serviceid;
                //servicesTable.PersonId = model.clientID;
                servicesTable.ServiceTypeId = model.ServiceTypeid;
                servicesTable.ServiceNotes  = model.ServiceNotes.Trim();
                servicesTable.DateCreated   = DateTime.Now;
                //Value 1 means record is not active(Not deleted)
                servicesTable.isActive = 1;

                dbContext.VEP_Services.Add(servicesTable);
                dbContext.SaveChanges();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
        }