//SellLotToBuyer public JsonExecuteResult SellLotToBuyer(long auction_id, long user_id) { try { Auction auction = dataContext.Auctions.Where(A => A.ID == auction_id).FirstOrDefault(); if (auction == null) { throw new Exception("The lot doesn't exist."); } if (auction.Status != (byte)Consts.AuctionStatus.Closed) { throw new Exception("You can sell only the items with the 'Closed' status."); } User user = dataContext.Users.Where(U => U.ID == user_id).FirstOrDefault(); if (user == null) { throw new Exception("The user doesn't exist."); } if (user.UserStatus_ID != (byte)Consts.UserStatus.Active || !user.IsBuyerType) { throw new Exception("You can't sell item to this user."); } dataContext.spInvoice_SellItemToBuyer(auction_id, user_id); } catch (Exception ex) { return(new JsonExecuteResult(JsonExecuteResultTypes.ERROR, ex.Message)); } return(new JsonExecuteResult(JsonExecuteResultTypes.SUCCESS)); }