public static void DeleteDeliverymans(string Name) { Deliveryman c = new Deliveryman(); c.Name = Name; db.Deliverymans.DeleteDeliverymans(c); }
public async Task <AuthenticationResponse> CreateDeliverymanAsync(Deliveryman deliveryman, string password) { if (string.IsNullOrWhiteSpace(deliveryman.FirstName) || string.IsNullOrWhiteSpace(deliveryman.LastName) || string.IsNullOrWhiteSpace(deliveryman.Email)) { return new AuthenticationResponse { Errors = new[] { "FirstName, LastName and Email cannot be empty" } } } ; var deliverymanExist = await _dataContext.DeliveryMen.FirstOrDefaultAsync(d => d.Email == deliveryman.Email || d.PhoneNumber == deliveryman.PhoneNumber); if (deliverymanExist != null) { if (!deliverymanExist.IsVerified) { return new AuthenticationResponse { Errors = new[] { "Deliveryman already exist but not verified." } } } ; return(new AuthenticationResponse { Errors = new[] { "Deliveryman with this email and phonenumber already exists." } }); } byte[] passwordHash, passwordSalt; try { Security.CreatePasswordHash(password, out passwordHash, out passwordSalt); } catch (Exception) { return(new AuthenticationResponse { Errors = new[] { "Error Occurred." } }); } deliveryman.PasswordHash = passwordHash; deliveryman.PasswordSalt = passwordSalt; deliveryman.DateRegistered = DateTime.Now; await _dataContext.DeliveryMen.AddAsync(deliveryman); var created = await _dataContext.SaveChangesAsync(); if (created <= 0) { return(new AuthenticationResponse { Errors = new[] { "Failed to register deliveryman." } }); } var token = GenerateAuthenticationTokenForDeliveryman(deliveryman); return(new AuthenticationResponse { Success = true, Token = token }); }
private string GenerateAuthenticationTokenForDeliveryman(Deliveryman deliveryman) { var claims = new[] { new Claim("FirstName", deliveryman.FirstName), new Claim("LastName", deliveryman.LastName), new Claim("Email", deliveryman.Email), new Claim("PhoneNumber", deliveryman.PhoneNumber), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) }; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtSettings.Secret)); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var token = new JwtSecurityToken( _jwtSettings.Issuer, _jwtSettings.Issuer, claims, expires: DateTime.UtcNow.AddMinutes(10), notBefore: DateTime.UtcNow, signingCredentials: creds ); return(new JwtSecurityTokenHandler().WriteToken(token)); }
/// <summary> /// This gets a list from getAllDocuments_For. /// </summary> /// <param name="orderListDateDelimitedByDocumentTypeAndState"></param> /// <returns></returns> decimal get_Money_For(List <BuySellDoc> orderListDateDelimitedByDocumentTypeAndState, BuySellDocumentTypeENUM buySellDocumentTypeEnum) { //get all purchase orders for Owner //add up the purchase amoung if (orderListDateDelimitedByDocumentTypeAndState.IsNullOrEmpty()) { return(0); } //The deliveryman is only counted once selected. if (buySellDocumentTypeEnum == BuySellDocumentTypeENUM.Delivery) { Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(UserId); if (deliveryman.IsNull()) { return(0); } } decimal ttlOrdered = orderListDateDelimitedByDocumentTypeAndState.Sum(x => x.TotalOrdered); //foreach (var item in orderListDateDelimitedByDocumentTypeAndState) //{ // ttlOrdered += item.TotalOrdered; //} return(ttlOrdered); }
public static List <Deliveryman> GetDeliverymen() { DataSet ds; var deliverymen = new List <Deliveryman>(); using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString)) { ds = MySqlHelper.ExecuteDataset(conn, "GetDeliverymen"); } foreach (DataRow row in ds.Tables[0].Rows) { Deliveryman deliveryman = new Deliveryman(); deliveryman.ID = (int)row["ID"]; deliveryman.FullName = row["first_name"].ToString() + ' ' + row["last_name"].ToString(); deliveryman.Salary = (int)row["salary"]; deliveryman.Username = row["username"].ToString(); deliveryman.Password = row["password"].ToString(); deliveryman.Approval = Convert.ToInt32(row["approval"]); deliveryman.DemotionCount = (int)row["demotion_count"]; deliveryman.PromotionCount = Convert.ToInt32(row["promotion_count"]); deliverymen.Add(deliveryman); } return(deliverymen); }
public static Chef PromoteDeliveryman(int DeliverymanID) { DataTable dt = new DataTable(); var Deliveryman = GetDeliverymen().Where(x => x.ID == DeliverymanID).FirstOrDefault(); Deliveryman.PromotionCount++; int PromotionCount = Deliveryman.PromotionCount; int NewSalary = Deliveryman.Salary + (5000 * PromotionCount); int DemotionCount = Deliveryman.DemotionCount == 0 ? 0 : Deliveryman.DemotionCount -= 1; using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString)) { using (MySqlCommand cmd = new MySqlCommand("PromoteDeliveryman", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("DeliverymanID", DeliverymanID); cmd.Parameters.AddWithValue("NewSalary", NewSalary); cmd.Parameters.AddWithValue("DemotionCount", DemotionCount); cmd.Parameters.AddWithValue("PromotionCount", PromotionCount); using (MySqlDataAdapter sda = new MySqlDataAdapter(cmd)) { sda.Fill(dt); } } } Deliveryman deliveryman = new Deliveryman(); deliveryman.ID = int.Parse(dt.Rows[0].ItemArray[0].ToString()); deliveryman.Salary = int.Parse(dt.Rows[0].ItemArray[5].ToString()); deliveryman.PromotionCount = int.Parse(dt.Rows[0].ItemArray[7].ToString()); return(deliveryman); }
public ActionResult DeleteConfirmed(int id) { Deliveryman deliveryman = db.Deliverymen.Find(id); db.Deliverymen.Remove(deliveryman); db.SaveChanges(); return(RedirectToAction("Index")); }
public static void ChanagePassword(String Email, String Password) { Deliveryman d = new Deliveryman(); d.Email = Email; d.Password = Password; db.Deliverymans.ChangePassword(d); }
public IActionResult GetDeliverymanById(int id) { Deliveryman meal = _context.Deliveryman.FirstOrDefault(m => m.IdDeliveryman == id); if (meal == null) { return(NotFound()); } return(Ok(meal)); }
public ActionResult Edit([Bind(Include = "DeliverymansID,DeliverymanName,Address,PhoneNo,CitizenshipNo")] Deliveryman deliveryman) { if (ModelState.IsValid) { db.Entry(deliveryman).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(deliveryman)); }
public IActionResult UpdateDeliveryman(Deliveryman deliveryman) { if (_context.Deliveryman.FirstOrDefault(d => d.IdDeliveryman == deliveryman.IdDeliveryman) == null) { return(NotFound()); } _context.Deliveryman.Attach(deliveryman); _context.Entry(deliveryman).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(Ok(deliveryman)); }
public ActionResult DeliverymenCreateModal([Bind(Include = "DeliverymansID,DeliverymanName,Address,PhoneNo,CitizenshipNo")] Deliveryman deliveryman) { if (ModelState.IsValid) { db.Deliverymen.Add(deliveryman); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(deliveryman)); }
private Deliveryman loadCurrentUsersDeliverymanIdIntoBuySellDoc(BuySellDoc buySellDoc) { //get the deliveryman Id for the current user. Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(UserId); deliveryman.IsNullThrowException(); //This is used in View OrderList to determine if the current user is the deliveryman //who is to accept the courier order request. buySellDoc.CurrentUser_DeliverymanId = deliveryman.Id; return(deliveryman); }
public int?Create(CreateDeliverymanViewModel deliveryman) { var objDeliveryman = new Deliveryman(deliveryman.Name); _deliverymanRepository.Create(objDeliveryman); if (Commit()) { return(objDeliveryman.IdDeliveryman); } return(null); }
public IActionResult DeleteDeliveryman(int id) { Deliveryman deliveryman = _context.Deliveryman.FirstOrDefault(d => d.IdDeliveryman == id); if (deliveryman == null) { return(NotFound()); } _context.Deliveryman.Remove(deliveryman); _context.SaveChanges(); return(Ok(deliveryman)); }
//Accueil livreur, affiche son nom et son adresse via le Modele DeliverymanCityViewModel public ActionResult HomeDeliveryman() { int idDeliveryman = HttpContext.Session.GetInt32("IdDeliveryman").GetValueOrDefault(); Deliveryman deliveryman = DeliverymanManager.GetDeliveryman(idDeliveryman); List <DeliverymanCityViewModel> deliverymanCity = new List <DeliverymanCityViewModel>(); DeliverymanCityViewModel deliverymanCityViewModel = new DeliverymanCityViewModel(); deliverymanCityViewModel.Deliverymens = deliveryman; deliverymanCityViewModel.Cities = CityManager.GetCity(deliveryman.FK_idCity); deliverymanCity.Add(deliverymanCityViewModel); return(View(deliverymanCity)); }
// GET: Deliverymen/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Deliveryman deliveryman = db.Deliverymen.Find(id); if (deliveryman == null) { return(HttpNotFound()); } return(View(deliveryman)); }
public static void AddDeliverymans(string Name, string Username, string Password, string Email, string Address, string Phone, string Gander, string DOB) { Deliveryman c = new Deliveryman(); c.Name = Name; c.Password = Password; c.Username = Username; c.Email = Email; c.Phone = Phone; c.Address = Address; c.Gander = Gander; c.DOB = DOB; db.Deliverymans.AddDeliverymans(c); }
public void Load_Current_User_As_Delyman_Id_Into_BuySellDoc_And_UpdateVarsWithEarlierOffer(BuySellDoc buySellDoc) { //check to see if the user has bid on this before. If yes, then find it and add the values. Deliveryman deliveryman = loadCurrentUsersDeliverymanIdIntoBuySellDoc(buySellDoc); FreightOfferTrx earlierOfferByUser = FreightOfferTrxBiz.FindAll().FirstOrDefault(x => x.BuySellDocId == buySellDoc.Id && x.DeliverymanId == deliveryman.Id); if (earlierOfferByUser.IsNull()) { } else { //an earlier bid has been found buySellDoc.UpdateFreightBidVars(earlierOfferByUser); } }
//public BuySellStatementModel GetDeliveryOrders(string userId, string id) //{ // userId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in."); // List<BuySellDoc> lstbuySellDocs = new List<BuySellDoc>(); ; // BuySellDoc buySellDoc = Find(id); // buySellDoc.IsNullThrowException(); // lstbuySellDocs.Add(buySellDoc); // decimal customerBalanceRefundable = 0; // decimal customerBalanceNonRefundable = 0; // BuySellStatementModel buySellStatementModel = new BuySellStatementModel(lstbuySellDocs, DateTime.MinValue, DateTime.MaxValue, BuySellDocumentTypeENUM.Delivery, false, customerBalanceRefundable, customerBalanceNonRefundable, BuySellDocStateENUM.ReadyForPickup); // return buySellStatementModel; //} /// <summary> /// This gets the order list of Sale or Purchase documents date delimited. /// This also figures out if it is a sale or a purchase /// </summary> /// <param name="userId"></param> /// <param name="buySellDocumentTypeEnum"></param> /// <param name="fromDate"></param> /// <param name="toDate"></param> /// <returns></returns> public BuySellStatementModel GetBuySellStatementModel(string userId, DateTime fromDate, DateTime toDate, bool isAdmin, BuySellDocumentTypeENUM buySellDocumentTypeEnum, BuySellDocStateENUM buySellDocStateEnum) { //userId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in."); List <BuySellDoc> buySellDocs = getBuySellDocs_For(userId, buySellDocStateEnum, buySellDocumentTypeEnum, fromDate, toDate).ToList(); decimal customerBalanceRefundable = 0, customerBalanceNonRefundable = 0; Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(userId); BuySellStatementModel buySellStatementModel = new BuySellStatementModel(buySellDocs, fromDate, toDate, buySellDocumentTypeEnum, isAdmin, customerBalanceRefundable, customerBalanceNonRefundable, deliveryman, buySellDocStateEnum); return(buySellStatementModel); }
public IActionResult Connexion(Deliveryman deliveryman) { int idDeliveryman = DeliverymanManager.GetIdDeliveryman(deliveryman.Login); string password = DeliverymanManager.GetPassword(idDeliveryman, deliveryman.Login); //Si ca correspond, passe à la vue HomeDeliveryman if (deliveryman.Password == password) { HttpContext.Session.SetInt32("IdDeliveryman", idDeliveryman); return(RedirectToAction("HomeDeliveryman", "Deliveryman", new { id = idDeliveryman })); } //Si ca ne correspond pas, reste sur la connexion else { return(View()); } }
//Retourne le Deliveryman en fonction de son ID public Deliveryman GetDeliveryman(int idDeliveryman) { Deliveryman deliveryman = null; try { using (SqlConnection cn = new SqlConnection(connectionString)) { string query = "Select * from Deliveryman WHERE Id = @id"; SqlCommand cmd = new SqlCommand(query, cn); cmd.Parameters.AddWithValue("@id", idDeliveryman); cn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { deliveryman = new Deliveryman(); deliveryman.IdDeliveryman = (int)dr["Id"]; deliveryman.Name = (string)dr["name"]; deliveryman.LastName = (string)dr["lastName"]; deliveryman.Address = (string)dr["address"]; deliveryman.Login = (string)dr["login"]; deliveryman.Password = (string)dr["password"]; deliveryman.FK_idCity = (int)dr["FK_idCity"]; } } } } catch (Exception e) { throw e; } return(deliveryman); }
//public override void Event_ModifyIndexList(IndexListVM indexListVM, ControllerIndexParams parameters) //{ // base.Event_ModifyIndexList(indexListVM, parameters); // indexListVM.Show.EditDeleteAndCreate = true; //} public override void Fix(ControllerCreateEditParameter parm) { base.Fix(parm); Deliveryman deliveryman = parm.Entity as Deliveryman; if (deliveryman.DeliverymanCategoryId.IsNullOrWhiteSpace()) { deliveryman.DeliverymanCategoryId = null; } if (deliveryman.Name.IsNullOrWhiteSpace()) { if (deliveryman.Person.IsNull()) { deliveryman.PersonId.IsNullOrWhiteSpaceThrowException(); deliveryman.Person = PersonBiz.Find(deliveryman.PersonId); deliveryman.Person.IsNullThrowException(); } deliveryman.Name = deliveryman.Person.Name; } }
IQueryable <BuySellDoc> getByDocumentType_For(string userId, IQueryable <BuySellDoc> iq_allOrders, BuySellDocumentTypeENUM buySellDocumentTypeEnum) { //userId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in."); switch (buySellDocumentTypeEnum) { case BuySellDocumentTypeENUM.Sale: { try { //all orders are returned because this is the admin //if (userId.IsNullOrWhiteSpace()) // return iq_allOrders; if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetSaleDocs(iq_allOrders, "")); } Owner owner = OwnerBiz.GetPlayerFor(userId); owner.IsNullThrowException("No Owner"); return(BuySellDoc.IQueryable_GetSaleDocs(iq_allOrders, owner.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting sales.", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Purchase: { try { //all orders are returned because this is the admin //if (userId.IsNullOrWhiteSpace()) // return iq_allOrders; if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetPurchaseDocs(iq_allOrders, "")); } Customer customer = CustomerBiz.GetPlayerFor(userId); customer.IsNullThrowException("Customer"); return(BuySellDoc.IQueryable_GetPurchaseDocs(iq_allOrders, customer.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Delivery: { try { //all orders are returned because this is the admin if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetDeliveryDocs(iq_allOrders, "")); } Deliveryman deliveryMan = DeliverymanBiz.GetPlayerFor(userId); deliveryMan.IsNullThrowException("deliveryMan"); return(BuySellDoc.IQueryable_GetDeliveryDocs(iq_allOrders, deliveryMan.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Salesman: { try { if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetSalesmanDocs(iq_allOrders, "")); } Salesman salesman = SalesmanBiz.GetPlayerFor(userId); salesman.IsNullThrowException("Salesman"); return(BuySellDoc.IQueryable_GetSalesmanDocs(iq_allOrders, salesman.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Unknown: default: throw new Exception("Unknown document type"); } }
public async Task <AuthenticationResponse> GoogleLoginDeliverymanAsync(GoogleAuthRequest request) { if (string.IsNullOrWhiteSpace(request.FirstName) || string.IsNullOrWhiteSpace(request.LastName) || string.IsNullOrWhiteSpace(request.Email)) { return new AuthenticationResponse { Errors = new[] { "FirstName, LastName and Email cannot be empty." } } } ; var deliverymanExist = await _dataContext.DeliveryMen.FirstOrDefaultAsync(d => d.Email == request.Email); if (deliverymanExist != null) //Sign Deliveryman in { deliverymanExist.LastLoginDate = DateTime.Now; _dataContext.Entry(deliverymanExist).State = EntityState.Modified; var updated = await _dataContext.SaveChangesAsync(); if (updated <= 0) { return new AuthenticationResponse { Errors = new[] { "Failed to signin." } } } ; var token = GenerateAuthenticationTokenForDeliveryman(deliverymanExist); return(new AuthenticationResponse { Success = true, Token = token }); } else // Register Deliveryman { var newDeliveryman = new Deliveryman() { Email = request.Email, FirstName = request.FirstName, MiddleName = request.MiddleName, LastName = request.LastName, PhoneNumber = request.PhoneNumber, ProfilePicUrl = request.ImageUrl, IsVerified = true, DateRegistered = DateTime.Now, IsGoogleRegistered = true }; await _dataContext.DeliveryMen.AddAsync(newDeliveryman); var created = await _dataContext.SaveChangesAsync(); if (created <= 0) { return new AuthenticationResponse { Errors = new[] { "Failed to register deliveryman." } } } ; var token = GenerateAuthenticationTokenForDeliveryman(newDeliveryman); return(new AuthenticationResponse { Success = true, Token = token }); } }
public async Task <AuthenticationResponse> FacebookLoginDeliverymanAsync(string accessToken) { if (string.IsNullOrWhiteSpace(accessToken)) { return new AuthenticationResponse { Errors = new[] { "AccessToken cannot be empty." } } } ; var validateTokenResult = await _facebookAuthService.ValidateAccessTokenAsync(accessToken); if (validateTokenResult.Data != null) { if (!validateTokenResult.Data.IsValid) { return new AuthenticationResponse { Errors = new[] { "Invalid Facebook Token." } } } ; var fbUserInfo = await _facebookAuthService.GetUserInfoAsync(accessToken); if (fbUserInfo.Id == "Failed") { return new AuthenticationResponse { Errors = new[] { "Failed to Get Facebook User. " } } } ; var deliverymanExist = await _dataContext.DeliveryMen.FirstOrDefaultAsync(d => d.Email == fbUserInfo.Email); if (deliverymanExist == null) //Register Deliveryman { var newDeliveryman = new Deliveryman() { Email = fbUserInfo.Email, FirstName = fbUserInfo.FirstName, MiddleName = fbUserInfo.MiddleName, LastName = fbUserInfo.LastName, PhoneNumber = string.Empty, ProfilePicUrl = fbUserInfo.Picture.FacebookPictureData.Url.ToString(), IsVerified = true, DateRegistered = DateTime.Now, IsGoogleRegistered = true }; await _dataContext.DeliveryMen.AddAsync(newDeliveryman); var created = await _dataContext.SaveChangesAsync(); if (created <= 0) { return new AuthenticationResponse { Errors = new[] { "Failed to create deliveryman" } } } ; var token = GenerateAuthenticationTokenForDeliveryman(newDeliveryman); return(new AuthenticationResponse { Success = true, Token = token }); } else //Signin Customer { deliverymanExist.LastLoginDate = DateTime.Now; _dataContext.Entry(deliverymanExist).State = EntityState.Modified; var updated = await _dataContext.SaveChangesAsync(); if (updated <= 0) { return new AuthenticationResponse { Errors = new[] { "Failed to signin." } } } ; var token = GenerateAuthenticationTokenForDeliveryman(deliverymanExist); return(new AuthenticationResponse { Success = true, Token = token }); } } else { return(new AuthenticationResponse { Errors = new[] { "Failed to Validate Facebook." } }); } }
public IActionResult AddDeliveryman(Deliveryman deliveryman) { _context.Deliveryman.Add(deliveryman); _context.SaveChanges(); return(Ok(deliveryman)); }
private void deliveryman_Makes_Bid_To_Pickup(BuySellDoc buySellDoc) { if (UserId.IsNullOrWhiteSpace()) { return; } if (buySellDoc.FreightOfferDecimal > 0) { //we have an offer DateParameter dp = new DateParameter(); dp.BeginDate = buySellDoc.PleasePickupOnDate_Start; dp.EndDate = buySellDoc.PleasePickupOnDate_End; if (dp.IsDateWithinBeginAndEndDatesInclusive(buySellDoc.OfferedPickupOnDate)) { string buySellDocId = buySellDoc.Id; buySellDoc = Find(buySellDocId); buySellDoc.IsNullThrowException(); //the pick up is today or later. //the user is the deliveryman here Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(UserId); deliveryman.IsNullThrowException(); //create an offer FreightOfferTrx frtOff = new FreightOfferTrx( buySellDoc.Id, deliveryman.Id, buySellDoc.FreightOfferDecimal, buySellDoc.OfferedPickupOnDate, buySellDoc.ExpectedDeliveryDate, buySellDoc.CommentByDeliveryman, buySellDoc.VehicalTypeOfferedId); //used later frtOff.Deliveryman = deliveryman; frtOff.BuySellDoc = buySellDoc; //we will only create if there is not one bid from this deliveryman //for this document. If there is already a bid, then all fields will be updated. //the change will only be allowed if the status of the buyselldoc is //check to see if a bid already exists. //this locates an earlier bid and then updates it. FreightOfferTrx frtOffTrxFound = FreightOfferTrxBiz.FindAll().FirstOrDefault(x => x.BuySellDocId == buySellDocId && x.DeliverymanId == deliveryman.Id); if (frtOffTrxFound.IsNull()) { //create a new bid. buySellDoc.FreightOfferTrxs.Add(frtOff); FreightOfferTrxBiz.Create(frtOff); } else { //update the old bid. frtOffTrxFound.UpdatePropertiesDuringModify(frtOff as ICommonWithId); FreightOfferTrxBiz.Update(frtOffTrxFound); } } } }
public static void UserSubmitReview(int UserID, int isVVIP, int ItemID, int ChefID, int DeliverymanID, int Rating, int DeliveryRating, int Approval, string Comment) { int Delivery_Approval = 0; if (DeliveryRating >= 3) { Delivery_Approval = 1; } else { Delivery_Approval = -1; } Deliveryman deliveryman = new Deliveryman(); var deliverymen = ManagerViewModel.GetDeliverymen(); for (int j = 0; j < deliverymen.Count; j++) { if (deliverymen[j].ID == DeliverymanID) { deliveryman = deliverymen[j]; } } if (Rating >= 3) { Approval = 1; } else { Approval = -1; } Chef chef = new Chef(); var ChefList = ManagerViewModel.GetChefs(); for (int i = 0; i < ChefList.Count; i++) { if (ChefList[i].ID == ChefID) { chef = ChefList[i]; } } if (isVVIP == 1) { Approval *= 2; Delivery_Approval *= 2; } chef.Approval += Approval; deliveryman.Approval += Delivery_Approval; using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString)) { DataTable dt = new DataTable(); using (MySqlCommand cmd = new MySqlCommand("UpdateChefApproval", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("ChefID", ChefID); cmd.Parameters.AddWithValue("Approval", chef.Approval); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString)) { DataTable dt = new DataTable(); using (MySqlCommand cmd = new MySqlCommand("UpdateDeliverymanApproval", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("DeliverymanID", DeliverymanID); cmd.Parameters.AddWithValue("Approval", deliveryman.Approval); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString)) { DataTable dt = new DataTable(); using (MySqlCommand cmd = new MySqlCommand("UserSubmitReview", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("UserID", UserID); cmd.Parameters.AddWithValue("ItemID", ItemID); cmd.Parameters.AddWithValue("ChefID", ChefID); cmd.Parameters.AddWithValue("Rating", Rating); cmd.Parameters.AddWithValue("Approval", Approval); cmd.Parameters.AddWithValue("Comment", Comment); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } } }