public object Save([FromBody] Order order) { if (order.Id <= 0) { throw new Exception("哦豁,没有获取到这个订单的Id。"); } string sql = ""; order.ActuallyPrice = order.ShouldPrice; order.DiscountRate = 1; sql = $@"UPDATE TotalOrder SET PositionId=@PositionId, IsBuyed=@IsBuyed WHERE Id = @Id"; var xresult = new XResult(); if (!XDataHelper.ExcuteNonQuery(sql, order)) { xresult.code = 10000; xresult.message = "操作失败!"; } ; return(xresult); }
public object Save([FromBody] Menu menu) { string sql = ""; if (menu.Id > 0) { sql = $@"UPDATE Menu SET Name=@Name, MenuTypeId=@MenuTypeId, IsUsed=@IsUsed, Price=@Price, PriceType=@PriceType, Description=@Description, IsUsed=@IsUsed, Sort=@Sort WHERE Id = @Id"; } else { sql = $@"INSERT INTO Menu(MenuTypeId, NAME, IsUsed,Price,PriceType,Description,CreateTime,Sort) VALUES(@MenuTypeId, @Name, @IsUsed,@Price,@PriceType,@Description,DATE_ADD(NOW(), INTERVAL 12 HOUR),@Sort)"; } var xresult = new XResult(); if (!XDataHelper.ExcuteNonQuery(sql, menu)) { xresult.code = 10000; xresult.message = "操作失败!"; } ; return(xresult); }
public object Save([FromBody] DetailOrder detailOrder) { string sql = ""; if (detailOrder.Weight == 0) { detailOrder.Weight = 1; } detailOrder.ShouldPrice = detailOrder.SinglePrice * detailOrder.Weight; if (detailOrder.Id > 0) { sql = $@"UPDATE DetailOrder SET MenuId=@MenuId, SinglePrice=@SinglePrice, Weight=@Weight, ShouldPrice=@ShouldPrice WHERE Id = @Id"; } else { sql = $@"INSERT INTO DetailOrder(MenuId, SinglePrice, Weight, ShouldPrice, OrderId) VALUES(@MenuId, @SinglePrice, @Weight, @ShouldPrice, @OrderId)"; } var xresult = new XResult(); if (!XDataHelper.ExcuteNonQuery(sql, detailOrder)) { xresult.code = 10000; xresult.message = "操作失败!"; } ; return(xresult); }
public object Delete(int id) { var result = new XResult(); var delete = "UPDATE BlogArticle SET DELETETIME=NOW(), IsDeleted=1 WHERE ID = @id"; if (XDataHelper.ExcuteNonQuery(delete, new { id })) { return(result); } result.Code = -1; result.Message = "操作失败"; return(result); }
public object Update(int id) { var result = new XResult(); var update = $@"UPDATE BlogArticle SET ReadCount = (ReadCount+1) WHERE ID = @id"; if (XDataHelper.ExcuteNonQuery(update, new { id })) { return(result); } result.Code = -1; result.Message = "操作失败"; return(result); }
public object Add([FromBody] BlogArticle model) { var result = new XResult(); var insert = $@"INSERT INTO BlogArticle (Title,Category,Tag,Content,ReadCount,CreateTime,ModifiedTime)VALUES ('{model.Title}','{model.Category}','{model.Tag}','{model.Content}',0,NOW(),NOW())"; if (XDataHelper.ExcuteNonQuery(insert)) { return(result); } result.Code = -1; result.Message = "操作失败"; return(result); }
public object Save([FromBody] Setting setting) { string sql = ""; sql = $"UPDATE TytfSetting SET Value=@Value WHERE Id = @Id"; var xresult = new XResult(); if (!XDataHelper.ExcuteNonQuery(sql, setting)) { xresult.code = 10000; xresult.message = "操作失败!"; } ; return(xresult); }
public object Del(string tableName, int id) { string sql = $"DELETE FROM {tableName.DelSpace()} WHERE Id = @id"; var xresult = new XResult(); xresult.message = "删除成功"; if (!XDataHelper.ExcuteNonQuery(sql, new { id })) { xresult.code = 10000; xresult.message = "操作失败!"; } ; return(xresult); }
public object DeleteOrder(string orderId) { string sql = @"DELETE FROM TotalOrder WHERE OrderId=@orderId; DELETE FROM DetailOrder WHERE OrderId=@orderId;"; var xresult = new XResult(); if (!XDataHelper.ExcuteNonQuery(sql, new { orderId })) { xresult.code = 10000; xresult.message = "操作失败!"; } ; return(xresult); }
public object NoBuy(string orderId) { string sql = $@"UPDATE TotalOrder SET IsBuyed=0 WHERE OrderId = @OrderId"; var xresult = new XResult(); if (!XDataHelper.ExcuteNonQuery(sql, new { orderId })) { xresult.code = 10000; xresult.message = "操作失败!"; } ; return(xresult); }
public object Add([FromBody] BlogArticle model) { var result = new XResult(); var insert = $@"INSERT INTO BlogArticle (Title,Image,Category,Tag,Content,ReadCount,CreateTime,ModifiedTime)VALUES (@Title,@Image,@Category,@Tag,@Content,0,Now(),Now())"; var whereObj = new { Category = model.Category, Image = model.Image, Tag = model.Tag, Title = model.Title, Content = model.Content }; if (XDataHelper.ExcuteNonQuery(insert, whereObj)) { return(result); } result.Code = -1; result.Message = "操作失败"; return(result); }
public object CreateOrder([FromBody] OrderTemp order) { var waiter = GetWaiter(order.WaiterName); string orderId = ""; int resultCount = 1; while (resultCount > 0) { orderId = GenerateOrderId(); string sqlExists = "SELECT OrderId FROM TotalOrder WHERE OrderId = @orderId"; var result = XDataHelper.ExcuteReader <object>(sqlExists, new { orderId }).ToList(); resultCount = result.Count; } order.OrderId = orderId; string sql = $@"INSERT INTO TotalOrder(OrderId,PositionId,ClientName,WaiterId,CreateTime,IsBuyed,Note) VALUES(@OrderId,@PositionId,@ClientName,{waiter.Id},DATE_ADD(NOW(), INTERVAL 12 HOUR),0,@Note);"; foreach (var item in order.detailTemps) { sql += $@"INSERT INTO DetailOrder(OrderId,MenuId,SinglePrice,Weight,ShouldPrice) VALUES(@OrderId,{item.MenuId},'{item.SinglePrice}',{item.Weight},'{item.ShouldPrice}');"; } var xresult = new XResult(); xresult.data = orderId; if (!XDataHelper.ExcuteNonQuery(sql, order)) { xresult.code = 10000; xresult.message = "操作失败!"; } ; return(xresult); }
public object Update(int id, [FromBody] BlogArticle model) { var result = new XResult(); var update = $@"UPDATE BlogArticle SET Title = @Title, Category = {model.Category}, Tag = @Tag, Content = @Content, ModifiedTime = '{DateTime.Now}' WHERE ID = @id"; var whereObj = new { id, Tag = model.Tag, Title = model.Title, Content = model.Content }; if (XDataHelper.ExcuteNonQuery(update, whereObj)) { return(result); } result.Code = -1; result.Message = "操作失败"; return(result); }
public object Save(string tableName, [FromBody] MenuType type) { string sql = ""; if (type.Id > 0) { sql = $"UPDATE {tableName.DelSpace()} SET Name=@Name,Sort=@Sort WHERE Id = @Id"; } else { sql = $"INSERT INTO {tableName.DelSpace()}(Sort, NAME) VALUES(@Sort, @Name)"; } var xresult = new XResult(); if (!XDataHelper.ExcuteNonQuery(sql, type)) { xresult.code = 10000; xresult.message = "操作失败!"; } ; return(xresult); }
public object Advice([FromBody] XAdvice advice) { var ip = HttpContext.Connection.RemoteIpAddress.ToString(); var sql = "INSERT INTO BlogAdvice(ArticleId,Email,NickName,Advice,CreateTime,IPAddress) VALUES (@ArticleId,@Email,@NickName,@Advice,NOW(),@IPAddress)"; var result = new XResult(); if (XDataHelper.ExcuteNonQuery(sql, new { ArticleId = advice.ArticleId, Email = advice.Email, NickName = advice.NickName, Advice = advice.Advice, IPAddress = ip })) { return(result); } result.Code = -1; result.Message = "哦豁,添加失败!"; return(result); }
public object Save([FromBody] Waiter waiter) { string sql = ""; if (waiter.Id > 0) { sql = $"UPDATE Waiter SET Name=@Name,WeiXinId=@WeiXinId,IsUsed=@IsUsed WHERE Id = @Id"; } else { sql = $"INSERT INTO Waiter(WeiXinId, NAME, IsUsed) VALUES(@WeiXinId, @Name, @IsUsed)"; } var xresult = new XResult(); if (!XDataHelper.ExcuteNonQuery(sql, waiter)) { xresult.code = 10000; xresult.message = "操作失败!"; } ; return(xresult); }