Exemplo n.º 1
0
 /// <summary>
 /// The Delete
 /// </summary>
 /// <param name="data">The <see cref="AssassinImage"/></param>
 /// <returns>The <see cref="Task"/></returns>
 internal async Task Delete(AssassinImage data)
 {
     try
     {
         await Delete(data.Id);
     }
     catch (Exception ex)
     {
         throw new Exception("Could not delete entity.", ex);
     }
 }
Exemplo n.º 2
0
 /// <inheritdoc />
 internal virtual object Get(AssassinImage data, bool includeAll)
 {
     try
     {
         using (var ctx = NewContext())
         {
             var list = DoLazyLoading(ctx.Set <AssassinImage>().Where(p => p.Id == data.Id), null, includeAll) as IQueryable <AssassinImage>;
             ctx.DetachAllEntities();
             return(list.FirstOrDefault());
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Could not get entity.", ex);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// The Create
        /// </summary>
        /// <param name="data">The <see cref="AssassinImage"/></param>
        /// <returns>The <see cref="Task{AssassinImage}"/></returns>
        internal async Task <AssassinImage> Create(AssassinImage data)
        {
            try
            {
                using (var ctx = NewContext())
                {
                    ctx.Set <AssassinImage>().AddRange(data);
                    await ctx.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Could not create entity.", ex);
            }

            return(data);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Deletes a image from the server.
 /// </summary>
 /// <param name="image">The image.</param>
 /// <returns>a task</returns>
 internal async Task DeleteImage(AssassinImage image)
 {
     try
     {
         WebPackage package = new WebPackage()
         {
             PackageType   = PackageType.Command,
             AssassinImage = image,
             Method        = PackageMethod.Delete
         };
         this.webservice.Send(package);
         image.Synced = true;
         await Task.Delay(1);
     }
     catch (Exception ex)
     {
         AssassinDataService.OnNotify?.Invoke(this, ex.ToText("Error sending data to server - method Delete failed."), LogLevel.Error);
     }
 }