public int CheckCustomerField(FormCollection form) { try { string customerEmailString = form["customerEmail"]; string customerAddressString = form["customerAddress"]; string customerPhoneNumberString = form["customerPhoneNumber"]; string customerTaxCodeString = form["customerTaxCode"]; string usernameString = form["username"]; OrderBusiness orderBusiness = new OrderBusiness(); return orderBusiness.CheckCustomerField(customerEmailString, customerAddressString, customerPhoneNumberString, customerTaxCodeString, usernameString); } catch (Exception) { return 0; } }
public int ApproveOrder(FormCollection form) { try { //Check autherization User staffUser = Session["User"] as User; if (staffUser == null || Session["UserRole"] == null || (int)Session["UserRole"] != 2) { return -7; } else { String customerName = form["customerName"]; if (customerName == null) { int orderId = Convert.ToInt32(form["orderId"]); int deposit = Convert.ToInt32(form["deposit"].Replace(".", "")); string deliveryDateString = form["deliveryDate"]; DateTime deliveryDate = DateTime.ParseExact(deliveryDateString, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture); OrderBusiness orderBusiness = new OrderBusiness(); return orderBusiness.ApproveOrder(orderId, deposit, deliveryDate, staffUser.UserId, null); } else { string orderIdString = form["orderId"]; string username = form["username"]; string email = form["customerEmail"]; string customerAddress = form["customerAddress"]; string customerPhoneNumber = form["customerPhoneNumber"]; string customerTaxCode = form["customerTaxCode"]; if (!(customerName.IsEmpty() || orderIdString.IsEmpty() || username.IsEmpty() || email.IsEmpty() || customerAddress.IsEmpty() || customerPhoneNumber.IsEmpty() || customerTaxCode.IsEmpty())) { OrderBusiness orderBusiness = new OrderBusiness(); int check = orderBusiness.CheckCustomerField(email, customerAddress, customerPhoneNumber, customerTaxCode, username); if (check != 0) { return check; } int orderId = Convert.ToInt32(orderIdString); int deposit = Convert.ToInt32(form["deposit"].Replace(".", "")); CustomerViewModel customer = new CustomerViewModel { Username = username, CustomerEmail = email, CustomerAddress = customerAddress, CustomerPhoneNumber = customerPhoneNumber, CustomerName = customerName, CustomerTaxCode = customerTaxCode }; DateTime deliveryDate = DateTime.ParseExact(form["deliveryDate"], "MM/dd/yyyy HH:mm", CultureInfo.InvariantCulture); int rs = orderBusiness.ApproveOrder(orderId, deposit, deliveryDate, staffUser.UserId, customer); return rs; } return 0; } } } catch (Exception) { return 0; } }