public Dalyan.Entities.Models.Product Handler(ProductAddQuery query) { try { var obj = new Dalyan.Db.Product(); obj.Id = query.Product.Id; obj.CompanyId = query.Product.CompanyId; obj.Name = query.Product.Name; obj.Description = query.Product.Description; obj.Price = query.Product.Price; obj.CreatedDate = query.Product.CreatedDate; obj.CreatedIpAddress = query.Product.CreatedIpAddress; obj.CreatedUserId = query.Product.CreatedUserId; obj.UpdatedDate = query.Product.UpdatedDate; obj.UpdatedIpAddress = query.Product.UpdatedIpAddress; obj.UpdatedUserId = query.Product.UpdatedUserId; obj.IsDeleted = query.Product.IsDeleted; _db.Product.Add(obj); _db.SaveChanges(); query.Product.Id = obj.Id; return(query.Product); } catch (Exception ex) { throw new ExceptionLog(LogType.DATABASE_INSERT, LogLevel.ERROR, ex, "AddQueryHandler"); } }
public Dalyan.Entities.Models.Product Handler(ProductEditQuery query) { try { var obj = new Dalyan.Db.Product(); obj = _db.Product.FirstOrDefault(x => x.Id == query.Product.Id); obj.Id = query.Product.Id; obj.CompanyId = query.Product.CompanyId; obj.Name = query.Product.Name; obj.Description = query.Product.Description; obj.Price = query.Product.Price; obj.CreatedDate = query.Product.CreatedDate; obj.CreatedIpAddress = query.Product.CreatedIpAddress; obj.CreatedUserId = query.Product.CreatedUserId; obj.UpdatedDate = query.Product.UpdatedDate; obj.UpdatedIpAddress = query.Product.UpdatedIpAddress; obj.UpdatedUserId = query.Product.UpdatedUserId; obj.IsDeleted = query.Product.IsDeleted; _db.SaveChanges(); return(query.Product); } catch (Exception ex) { throw new ExceptionLog(LogType.DATABASE_UPDATE, LogLevel.ERROR, ex, "EditQueryHandler"); } }
public bool Handler(Dalyan.Domain.Query.ProductDeleteQuery query) { try { var obj = new Dalyan.Db.Product(); obj = _db.Product.FirstOrDefault(x => x.Id == query.Id); obj.IsDeleted = true; _db.SaveChanges(); return(true); } catch (Exception ex) { throw new ExceptionLog(LogType.DATABASE_DELETE, LogLevel.ERROR, ex, "DeleteQueryHandler"); } }