示例#1
0
        public DeleteMethodResponse Delete(int id)
        {
            var response = new DeleteMethodResponse();
            try
            {
                var method = new Method { Id = id };
                DataContext.Methods.Attach(method);
                DataContext.Entry(method).State = EntityState.Deleted;
                DataContext.SaveChanges();
                response.IsSuccess = true;
                response.Message = "Method item has been deleted successfully";
            }
            catch (DbUpdateException dbUpdateException)
            {
                response.Message = dbUpdateException.Message;
            }

            return response;
        }
示例#2
0
 public void Install()
 {
     var method1 = new Method
     {
         Id = 1,
         Name = "Formula",
         IsActive = true
     };
     var method2 = new Method {
         Id = 2,
         Name = "External Source",
         IsActive = true
     };
     var method3 = new Method {
         Id = 3,
         Name = "Manual Input"
     };
     _dataContext.Methods.AddOrUpdate(method1);
     _dataContext.Methods.AddOrUpdate(method2);
     _dataContext.Methods.AddOrUpdate(method3);
 }