public async Task <DealModel> PostDealWithRetryAsync(DealPostModel model, bool retry = true) { DealModel deal = null; try { deal = await PostDealAsync(_token, model); } catch (AuthorizationException) { if (retry) { await RenewAuthToken(); deal = await PostDealAsync(_token, model); } else { throw; } } catch (Exception) { throw; } return(deal); }
/// <summary> /// Closing Deal successfuly(Finall stage). Could be called By book Donor(previous owner) /// </summary> /// <param name="theDeal"></param> /// <returns>HttpResponseMessage OK/BadRequest</returns> public async Task <HttpResponseMessage> CloseDeal([FromBody] DealModel theDeal) { try { Deal deal = await _context.Deals.FirstOrDefaultAsync(d => d.Id == theDeal.Dealid); deal.DealStatusId = (int?)DealHelper.Status.CLOSED; deal.ModifiedOn = DateTime.UtcNow; deal.ExpiredOn = DateTime.UtcNow; deal.EndedOn = DateTime.UtcNow; _context.SaveChanges(); var bookRecipient = _context.Users.FirstOrDefault(u => u.Id == deal.AcceptorId); var bookOwner = _context.Users.FirstOrDefault(u => u.Id == deal.DonorId); if (!String.IsNullOrEmpty(bookOwner.Email)) { GmailSender.SmtpClientLibrary.SendOrderRequestMessages(bookOwner.Email, responceDictionary["Close"], "Closed request", "mail", "pass"); } if (!String.IsNullOrEmpty(bookRecipient.Email)) { GmailSender.SmtpClientLibrary.SendOrderRequestMessages(bookRecipient.Email, responceDictionary["Close"], "Closed request", "mail", "pass"); } return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } }
public ActionResult Update(DealModel model) { if (ModelState.IsValid) { string fileName = ""; if (model.Image != null) { fileName = DateTime.Now.ToFileTime() + Path.GetExtension(model.Image.FileName); model.DealImage = "~/UploadFiles/Deals/" + fileName; } int result = model.Update(model); if (result > 0) { if (model.Image != null) { model.Image.SaveAs(Server.MapPath(model.DealImage)); } return(RedirectToAction("Index")); } } return(View(model)); }
public async Task <DealModel> GetDealFromIdWithRetryAsync(string deal_id, bool retry = true) { DealModel deal = null; try { deal = await GetDealFromIdAsync(_token, deal_id); } catch (AuthorizationException) { if (retry) { await RenewAuthToken(); deal = await GetDealFromIdAsync(_token, deal_id); } else { throw; } } catch (Exception) { throw; } return(deal); }
private void ShowDeal(DealModel dealModel) { if (dealModel != null) { SelectedDeal = dealModel; DropDealVisibility = Visibility.Visible; } else { SelectedDeal = new DealModel { Appartment = new Appartment(), Client = new Client() }; DropDealVisibility = Visibility.Collapsed; } ExistingDealVisibility = dealModel != null ? Visibility.Visible : Visibility.Collapsed; NewDealVisibility = dealModel == null ? Visibility.Visible : Visibility.Collapsed; SelectedDealVisibility = Visibility.Visible; ToolBarVisibility = Visibility.Collapsed; }
/// <summary> /// 查询不确定的交易 /// </summary> /// <param name="dealModel"></param> /// <param name="msg"></param> /// <returns></returns> public static void Getuncertaintytrade(DealModel dealModel) { if (yhObject == null) { yhObject = System.Activator.CreateInstance(yh); } yh_interface_getuncertaintytrade(dealModel.TransactionNumber, ref dealModel.TransactionOutputXml, ref dealModel.along_appcode, ref dealModel.Msg); }
/// <summary> /// 确认交易(只需要传入流水号,和交易码来确认交易) /// </summary> /// <param name="dealModel"></param> /// <param name="msg"></param> /// <returns></returns> public static void ConfirmDeal(DealModel dealModel) { if (yhObject == null) { yhObject = System.Activator.CreateInstance(yh); } yh_interface_confirm(dealModel.SerialNumber, dealModel.VerificationCode, ref dealModel.along_appcode, ref dealModel.Msg); }
/// <summary> /// 取消交易(只需要传入交易流水号) /// </summary> /// <param name="dealModel"></param> /// <param name="msg"></param> /// <returns></returns> public static void CancelDeal(DealModel dealModel) { if (yhObject == null) { yhObject = System.Activator.CreateInstance(yh); } yh_interface_cancel(dealModel.SerialNumber, ref dealModel.along_appcode, ref dealModel.Msg); }
private void UpdateDealFromModel(Deal target, DealModel source) { target.DealId = source.DealId; target.PropertyMergeId = Convert.ToInt32(source.PropertyMergeId ?? "0"); target.CompanyId = Convert.ToInt32(source.CompanyId ?? "0"); target.SaleValue1 = source.SaleValue1; target.SaleValue2 = source.SaleValue2; }
public async Task <DealModel> Add(DealModel item) { await this.context.Deals.AddAsync(item); await this.context.SaveChangesAsync(); return(item); }
public async Task <DealModel> Update(DealModel item) { if (item != null) { this.context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified; await this.context.SaveChangesAsync(); } return(item); }
public async Task <DealModel> CreateDeal(DealModel model) { model.ID = Guid.NewGuid(); var result = await _repo.Add(model); result = await this.UpdateDealImage(result, model); return(result); }
public ActionResult Update(int?id, DealModel model) { if (id != null) { model = model.GetDealById(id); } return(View(model)); }
/// <summary> /// Declines the request on Book. Could be called by Current book owner or by reqester. /// </summary> /// <param name="theDeal"></param> /// <returns>HttpResponseMessage OK/BadRequest</returns> public async Task <HttpResponseMessage> DeclineDeal([FromBody] DealModel theDeal) { try { var userId = User.Claims.FirstOrDefault(C => C.Type == ClaimTypes.NameIdentifier).Value; var user = _context.Users.FirstOrDefault(u => u.Id == int.Parse(userId)); if (user == null) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } Deal deal = await _context.Deals.Where(d => d.Id == theDeal.Dealid).Include(d => d.Book).FirstOrDefaultAsync(); if (deal.DealStatusId == (int?)DealHelper.Status.RECIEVED) { var bookHistoryRecords = _context.BookHistoryRecords .Where(bh => bh.BookId == deal.BookId) .OrderByDescending(bh => bh.GetBookOn) .Take(2).ToList(); _context.BookHistoryRecords.Remove(bookHistoryRecords[0]); bookHistoryRecords[1].GiveBookOn = null; deal.Book.CurrentUserId = user.Id; } deal.DealStatusId = (int?)DealHelper.Status.DECLINED; deal.ModifiedOn = DateTime.UtcNow; deal.ExpiredOn = DateTime.UtcNow; deal.EndedOn = DateTime.UtcNow; _context.SaveChanges(); var bookRecipient = _context.Users.FirstOrDefault(u => u.Id == deal.AcceptorId); var bookOwner = _context.Users.FirstOrDefault(u => u.Id == deal.DonorId); if (!String.IsNullOrEmpty(bookOwner.Email)) { GmailSender.SmtpClientLibrary.SendOrderRequestMessages(bookOwner.Email, responceDictionary["DenyDonor"], "Declined request", "mail", "pass"); } if (!String.IsNullOrEmpty(bookRecipient.Email)) { GmailSender.SmtpClientLibrary.SendOrderRequestMessages(bookRecipient.Email, responceDictionary["DenyAcceptor"], "Declined request", "mail", "pass"); } return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } }
public frmDeal(BusinessObjectServiceClient boServiceClient) { InitializeComponent(); _boServiceClient = boServiceClient; _dealModel = new DealModel(boServiceClient); _loadingModel = new DealForeignsModel(boServiceClient); InitControls(); InitEvents(); DisableControls(); }
public frmDeal(BusinessObjectServiceClient boServiceClient, Deal deal) { InitializeComponent(); _dealModel = new DealModel(boServiceClient, deal); _loadingModel = new DealForeignsModel(boServiceClient); InitControls(); InitEvents(); SetReadonly(true); Text = "Просмотр заявки(сделки)"; }
public static object ToDealRequest(this DealModel model) { return(new { associations = new { associatedCompanyIds = model.AssociationCompanies, associatedVids = model.AssociationContacts }, properties = model.Property.ToDealProperty() }); }
public async Task <int> DeleteDealAsync(DealModel model) { var deal = new Deal { DealId = model.DealId }; using (var dataService = DataServiceFactory.CreateDataService()) { return(await dataService.DeleteDealAsync(deal)); } }
/// <summary> /// 交易主函数,完成所有医疗业务的实际处理(可能存在用户交互界面) /// </summary> /// <param name="dealModel"></param> public static void CallDeal(DealModel dealModel) { yh_interface_call( dealModel.TransactionNumber, dealModel.TransactionControlXml, dealModel.TransactionInputXml, ref dealModel.BatchNo, ref dealModel.SerialNumber, ref dealModel.VerificationCode, ref dealModel.TransactionOutputXml, ref dealModel.along_appcode, ref dealModel.Msg); }
public ActionResult Edit(int id, DealModel ModelObject) { try { DealRepository repository = new DealRepository(); repository.Update(ModelObject); return(RedirectToAction("GetAll")); } catch { return(View()); } }
static public async Task <DealModel> CreateDealModelAsync(Deal source, bool includeAllFields) { var model = new DealModel() { PropertyMergeId = source.PropertyMergeId.ToString(), DealId = source.DealId, DealName = source.DealName, CompanyId = source.CompanyId.ToString(), SaleValue1 = source.SaleValue1.ToString("N"), SaleValue2 = source.SaleValue2.ToString("N"), Amount1 = Convert.ToDecimal(source.Amount1).ToString("N"), Amount2 = Convert.ToDecimal(source.Amount2).ToString("N") }; if (source.DealParties != null && source.DealParties.Count > 0) { model.DealParties = new ObservableCollection <DealPartiesModel>(); foreach (var obj in source.DealParties) { model.DealParties.Add(new DealPartiesModel { DealId = obj.DealId, DealPartyId = obj.DealPartyId, PartyId = obj.PartyId, PartyName = obj.PartyName, IsGroup = obj.IsGroup }); } } if (source.DealPaySchedules != null && source.DealPaySchedules.Count > 0) { model.DealPaySchedules = new ObservableCollection <DealPayScheduleModel>(); foreach (var obj in source.DealPaySchedules) { model.DealPaySchedules.Add(new DealPayScheduleModel { DealId = obj.DealId, DealPayScheduleId = obj.DealPayScheduleId, Description = obj.Description, ScheduleDate = obj.ScheduleDate, Amount1 = obj.Amount1.ToString("N"), Amount2 = obj.Amount2.ToString("N") }); } } return(model); }
private async Task <DealModel> UpdateDealImage(DealModel result, DealModel data) { if (result != null && data.Logo != null) { var img = await this._imgRepo.Find(data.Logo.ID.ToString()); if (img != null) { img.RefrenceID = data.ID; } await this._imgRepo.Update(img); data.Logo = img; } return(data); }
public async Task <int> AddDealAsync(DealModel model) { using (var dataService = DataServiceFactory.CreateDataService()) { var deal = new Deal(); UpdateDealFromModel(deal, model); if (model.DealParties != null && model.DealParties.Count > 0) { var list = new List <DealParties>(); foreach (var obj in model.DealParties) { if (obj.DealPartyId > 0) { continue; } var dealParty = new DealParties(); UpdateDealPartiesFromModel(dealParty, obj); dealParty.DealPartyId = 0; list.Add(dealParty); } deal.DealParties = list; } if (model.DealPaySchedules != null && model.DealPaySchedules.Count > 0) { var list = new List <DealPaySchedule>(); foreach (var obj in model.DealPaySchedules) { if (obj.DealPayScheduleId > 0) { continue; } var pay = new DealPaySchedule(); UpdateDealPayScheculeFromModel(pay, obj); pay.DealPayScheduleId = 0; list.Add(pay); } deal.DealPaySchedules = list; } var dealId = await dataService.AddDealAsync(deal); model.Merge(await GetDealsAsync(dataService, dealId)); return(dealId); } }
public ActionResult Delete(DealModel dealModel) { var deal = DataContext.Deals.Find(dealModel.Id); if (User.IsInRole("Admin") || deal.Creator_User_Id != null && User.Identity.GetUserId() == deal.Creator_User_Id) { deal.Archived = true; return(RedirectToAction("Index")); } else { AddClientMessage(ClientMessage.Warning, "Only Administrators and Wonder creator may delete a Wonder"); return(View()); } }
private DealResponse Add(DealModel model) { DealResponse Deal = new DealResponse(); string url = GetUrl(UrlType.Deal, UrlSubType.DealAdd); Synergy.Common.Request.WebClient client = new Synergy.Common.Request.WebClient(); HttpWebResponse response = client.Post(JsonConvert.SerializeObject(model.ToDealRequest()), url, AuthorizationHeader.GetAuthorizationToken(_AccessToken.Accesstoken), EnumUtilities.GetDescriptionFromEnumValue(ContentTypes.JSON)); if (response.StatusCode == HttpStatusCode.OK) { var responseStream = response.GetResponseStream(); StreamReader streamReader = new StreamReader(responseStream); string rawResponse = streamReader.ReadToEnd(); Deal = JsonConvert.DeserializeObject <DealResponse>(rawResponse); } return(Deal); }
public ActionResult Create(DealModel ModelObject) { try { if (ModelState.IsValid) { DealRepository repository = new DealRepository(); repository.Add(ModelObject); return(RedirectToAction("GetAll")); } return(View()); } catch { return(View()); } }
public async Task <string> AddNewDeal(DealModel dealModel) { Deal deal = new Deal() { Id = dealModel.Id, CustomerId = dealModel.CustomerId, PropertyId = dealModel.PropertyId, SalespersonId = dealModel.SalespersonId, Commission = dealModel.Commission, Price = dealModel.Price, CreatedOn = DateTime.Now }; await _RealEstateDB.Deals.AddAsync(deal); await _RealEstateDB.SaveChangesAsync(); return(dealModel.Id); }
// GET: Deal/Create public ActionResult Create() { AuctionRepository auctionRep = new AuctionRepository(); ParticipantRepository participantRep = new ParticipantRepository(); DealStateRepository dealStateRep = new DealStateRepository(); ItemRepository itemRep = new ItemRepository(); DealModel model = new DealModel { Auctions = auctionRep.GetAll(), Buyers = participantRep.GetAll(), Sellers = participantRep.GetAll(), DealStates = dealStateRep.GetAll(), Items = itemRep.GetAll() }; return(View(model)); }
public ActionResult Deal(int quoteId) { var quote = session.QueryOver <Quote>() .Where(q => q.Id == quoteId) .SingleOrDefault(); if (quote == null || quote.HasExpired(DateTimeOffset.UtcNow)) { return(RedirectToAction("Quote")); } var model = new DealModel(); model.Quote = quote; model.QuoteId = quoteId; return(View(model)); }
// GET: Deal/Edit/5 public ActionResult Edit(int id) { DealRepository repository = new DealRepository(); AuctionRepository auctionRep = new AuctionRepository(); ParticipantRepository participantRep = new ParticipantRepository(); DealStateRepository dealStateRep = new DealStateRepository(); ItemRepository itemRep = new ItemRepository(); DealModel model = repository.GetById(id); model.Auctions = auctionRep.GetAll(); model.Buyers = participantRep.GetAll(); model.Sellers = participantRep.GetAll(); model.DealStates = dealStateRep.GetAll(); model.Items = itemRep.GetAll(); return(View(model)); }