Пример #1
0
 public static Incident ToDataModel(this Contracts.Incident.CreateIncident create, RAAPEntities db)
 {
     return(new Incident
     {
         Name = create.Name,
         Description = create.Description,
         CreatedOn = DateTime.Now,
         UpdatedOn = DateTime.Now,
     });
 }
Пример #2
0
        public Contracts.Incident.Incident Create(Contracts.Incident.CreateIncident createIncident)
        {
            using (var db = new RAAPEntities(GetConnectionString()))
            {
                if (db.Incidents.Any(a => a.Name == createIncident.Name))
                {
                    throw new RAAPConflictException("Name is already in use, please try another name.");
                }
                var process = createIncident.ToDataModel(db);
                db.Incidents.Add(process);

                db.SaveChanges();

                return(process.ToContract());
            }
        }