/// <summary> /// The update complete status /// Author: ThanhDT /// Created date: 8/11/2020 2:53 PM /// </summary> /// <param name="orderId">The order identifier.</param> /// <param name="changeStatus">The change status.</param> /// <param name="deliveryStatus">The delivery status.</param> /// <param name="reasonNote">The reason note.</param> /// <param name="user">The user.</param> /// <returns></returns> public ErrorCodes UpdateCompleteStatus(int orderId, OrderStatusEnum changeStatus, DeliveryStatus deliveryStatus, string reasonNote = "", string user = "") { Entities.Order order; try { order = _orderDal.GetById(orderId); } catch (Exception ex) { Logger.Error(ex); return(ErrorCodes.Exception); } if (order == null || order.order_id == 0) { return(ErrorCodes.UnknowError); } //var currentStatus = (OrderStatusEnum)order.status; // Bắt buộc trạng thái trước đó phải là Delivering /*if (currentStatus != OrderStatusEnum.Delivering || !ValidateChangeStatus(currentStatus, changeStatus)) * { * return ErrorCodes.StatusError; * }*/ var changeStatusShort = (short)changeStatus; int result; try { result = _orderDal.UpdateCompleteStatus(orderId, changeStatusShort, (short)deliveryStatus, user, reasonNote: order.reason_note); } catch (Exception ex) { Logger.Error(ex); return(ErrorCodes.Exception); } ErrorCodes errorCodes; if (result <= 0) { errorCodes = ErrorCodes.BusinessError; } else { _orderHistoryBo.Insert(new OrderHistory { change_log = reasonNote, created_by = user, order_id = orderId, status = changeStatusShort }); errorCodes = ErrorCodes.Success; } return(errorCodes); }