Пример #1
0
        public APIResult <bool> Delete(int id)
        {
            try
            {
                using (var ctx = new MainEntities())
                {
                    var obj = ctx.Set <DAL.tbl_vehicles>().Find(id);
                    obj.is_delete        = true;
                    ctx.Entry(obj).State = System.Data.Entity.EntityState.Modified;

                    if (ctx.SaveChanges() <= 0)
                    {
                        return(APIResult <bool> .Error(ResponseCode.BackendDatabase, "Error while saving data!", false));
                    }
                    return(APIResult <bool> .Success(true, "API_SUCCESS"));
                }
            }
            catch (Exception ex)
            {
                return(APIResult <bool> .Error(ResponseCode.BackendDatabase, ex.Message));
            }
        }