public async Task <ActionResult> Activate(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } offer offer = await db.offer.FindAsync(id); if (offer == null) { return(HttpNotFound()); } if (!ValidateProductOffers(offer)) { return(HttpNotFound()); } offer.DeletionDatetime = null; db.Entry(offer).State = EntityState.Modified; db.Configuration.ValidateOnSaveEnabled = false; await db.SaveChangesAsync(); db.Configuration.ValidateOnSaveEnabled = true; return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
internal offer GetAvailableOffer(DateTime selectedCheckIn, DateTime selectedCheckOut) { HotelEntities context = new HotelEntities(); offer aux = new offer(); bool foundOffer = false; foreach (var offer in context.offers.ToList()) { if (offer.startDate <= selectedCheckIn && offer.dueDate >= selectedCheckOut && (selectedCheckOut - selectedCheckIn).Days == offer.nrBookedRooms) { aux = offer; foundOffer = true; } } if (foundOffer == false) { foreach (var offer in context.offers.ToList()) { if (offer.id == 3) { aux = offer; } } } return(aux); }
public ActionResult Edit(offer o, transaction_table t, loginfo l) { if (ModelState.IsValid) { t.Transaction_Name = "POSTPAIDBILL"; t.Type = "Postpaid"; t.time = System.DateTime.Now.ToShortTimeString(); t.date = System.DateTime.Now.ToShortDateString(); t.offer_recharge_consumer_numbers = o.offercode; db.transaction_table.Add(t); if (db.SaveChanges() > 0) { Session["offer"] = "OFFER GET SUCCESSFULLY"; o.Account_No = string.Empty; o.amount = string.Empty; o.mpin = string.Empty; db.Entry(o).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ModelState.Clear(); l.Balance = l.Balance - t.amount; db.Entry(l).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } else { Session["BILL"] = "*ALL FIELDS MUST FILLED"; } return(View()); }
//Action public void MakeTheCheckedBill(string path, string course, string pathtosave) { DeepCopier copier = new DeepCopier(); GetDataFromBill(path); GammaMod.GetAll(); foreach (var billposition in bills) { FurcomMod.GetByName(billposition.Name.GeneralName); FurcomIdReceiver IdReceiver = new FurcomIdReceiver(); FurcomModel loc = (FurcomModel)FurcomMod; string id = IdReceiver.GetIdFromFurcomProductDescr(loc.SelectedData[0].Description); CheckerGammaList GetterFromGamma = new CheckerGammaList(); GammaModel loc2 = (GammaModel)GammaMod; GetterFromGamma.FindOfferInGammaBase(id, loc2.SelectedData); offer result = GetterFromGamma.FoundOffer; BillData newbilldata = copier.DeepClone <BillData>(billposition); // это надо проверить decimal targetprice = ConvertRURintoBYN(course, result.Price); ChangeBillDataAmounts(newbilldata, targetprice); OutputBills.Add(newbilldata); } BillFormer former = new BillFormer(); former.FormBill(pathtosave, OutputBills, Raredata); }
public ActionResult DeleteConfirmed(int id) { offer offer = db.Offers.Find(id); db.Offers.Remove(offer); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void Page_Load(object sender, EventArgs e) { siteUser theUser = Session["offerUser"] as siteUser; offer theOffer = Session["myOffer"] as offer; nmeBTN.Text = theUser.outputName(); infoTXT.Text = theOffer.ToString() + "\n\n" + theUser.outputInfo(); roomTXT.Text = theOffer.offerRoom.ToString(); }
// GET api/values public List<offer> GetOffers() { List<offer> ofr = new List<offer>(); offer of = new offer(); of.offerID = 1; of.Available_On = 'O'; of.Coupen_Code = "OCT50"; of.Offer_Image1_Path = "http://placehold.it/50x50&text=img1"; of.Offer_image2_Path = "http://placehold.it/120x120&text=img1"; ; of.Offer_Title = "10% off with sbi credit"; of.Offer_Link = "d"; of.moreDescription = "recharge your mobile with paytm and get 50% cash back"; ofr.Add(of); offer of2 = new offer(); of2.offerID = 1; of2.Available_On = 'S'; of2.Coupen_Code = "OCT10"; of2.Offer_Image1_Path = "http://placehold.it/50x50&text=img2"; of2.Offer_image2_Path = "http://placehold.it/120x120&text=img2"; of2.Offer_Title = "50% off on offer"; of2.Offer_Link = "www.google.com"; of2.moreDescription = "book your bus ticket with redbus and get 20% cash back"; ofr.Add(of2); return ofr; //SqlConnection conn = null; //SqlDataReader rdr = null; //Console.WriteLine("\nTop 10 Most Expensive Products:\n"); //try //{ // conn = new SqlConnection("Server=(local);DataBase=master;Integrated Security=SSPI"); // conn.Open(); // SqlCommand cmd = new SqlCommand("dbo.test", conn); // cmd.CommandType = CommandType.StoredProcedure; // rdr = cmd.ExecuteReader(); // /*while (rdr.Read()) // { // Console.WriteLine( // "Product: {0,-25} Price: ${1,6:####.00}", // rdr["TenMostExpensiveProducts"], // rdr["UnitPrice"]); // }*/ //} //finally //{ // if (conn != null) // { // conn.Close(); // } // if (rdr != null) // { // rdr.Close(); // } //} }
public ActionResult deleteoffer(int offerid) { offer f = (from f1 in db.offers where f1.offerid == offerid select f1).Single(); db.offers.Remove(f); db.SaveChanges(); return(RedirectToAction("offers")); }
public ActionResult Edit([Bind(Include = "Id,Title,Dis,NoShots,NoCopy,Price,points,thumb,available")] offer offer) { if (ModelState.IsValid) { db.Entry(offer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(offer)); }
public ActionResult Create([Bind(Include = "Id,Title,Dis,NoShots,NoCopy,Price,points,thumb,available")] offer offer) { if (ModelState.IsValid) { db.Offers.Add(offer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(offer)); }
protected void submitBTN_Click(object sender, EventArgs e) { if (validOffer()) { offer theOffer = new offer(thisRm.roomHotel, thisRm, Session["User"] as customer, Convert.ToInt32(numDRP.SelectedItem.Text), fCAL.SelectedDate, lCAL.SelectedDate, Convert.ToDouble(offerPRC.Text)); Response.Redirect("~//roomDisp.aspx"); } else { errorTXT.Visible = true; } }
private bool ValidateProductOffers(offer offer) { var a = db.offer.Where(o => o.IdOffer != offer.IdOffer && o.IdProduct == offer.IdProduct && !o.DeletionDatetime.HasValue && (!o.ExpirationDatetime.HasValue || o.ExpirationDatetime > DateTime.Now)).FirstOrDefault(); if (db.offer.Where(o => o.IdOffer != offer.IdOffer && o.IdProduct == offer.IdProduct && !o.DeletionDatetime.HasValue && (!o.ExpirationDatetime.HasValue || o.ExpirationDatetime > DateTime.Now)).FirstOrDefault() != null) { ModelState.AddModelError("DuplicateOffer", "El producto ya tiene una oferta vigente."); return(false); } return(true); }
// POST: odata/offer public async Task <IHttpActionResult> Post(offer offer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.offer.Add(offer); await db.SaveChangesAsync(); return(Created(offer)); }
public void OfferSimple_GivenBarcodes_ShouldHaveRightBarcodes() { var offer = new offer(id: "12346", price: 600, currencyId: CurrencyEnum.EUR, categoryId: 1, name: "Наручные часы Casio A1234567B") { barcode = new[] { "423424", "43423423", "5353523" }, }; var xOffer = new YmlSerializer().ToXDocument(offer).Root; xOffer.Should().HaveElement("barcode"); // ReSharper disable once PossibleNullReferenceException xOffer.Descendants("barcode").Count().Should().Be(3); }
public void OfferSimple_GivenRequiredParameters_ShouldHaveRightProperties() { var offer = new offer(id: "12346", price: 600, currencyId: CurrencyEnum.EUR, categoryId: 1, name: "Наручные часы Casio A1234567B"); var xOffer = new YmlSerializer().ToXDocument(offer).Root; xOffer.Should().NotBeNull(); xOffer.Should().HaveAttribute("id", "12346"); xOffer.Should().HaveElement("price").Which.Should().HaveValue("600"); xOffer.Should().HaveElement("currencyId").Which.Should().HaveValue(CurrencyEnum.EUR.ToString()); xOffer.Should().HaveElement("categoryId").Which.Should().HaveValue(1.ToString()); xOffer.Should().HaveElement("name").Which.Should().HaveValue("Наручные часы Casio A1234567B"); }
// GET: /Offers/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } offer offer = db.Offers.Find(id); if (offer == null) { return(HttpNotFound()); } return(View(offer)); }
public void FindOfferInGammaBase(string id, List <offer> listoffer) { try { FoundOffer = listoffer.FirstOrDefault <offer>(g => g.ImagePath.Contains(id)); } catch { FoundOffer = new offer() { ProductName = "nomatch" }; } }
// DELETE: odata/offer(5) public async Task <IHttpActionResult> Delete([FromODataUri] int key) { offer offer = await db.offer.FindAsync(key); if (offer == null) { return(NotFound()); } offer.ModificationDatetime = DateTime.UtcNow; await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
// GET: /offer/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } offer offer = await db.offer.FindAsync(id); if (offer == null) { return(HttpNotFound()); } GetProducts(offer); return(View(offer)); }
// GET: /offer/Create public ActionResult Create(int IdProduct = 0) { offer offer = null; if (IdProduct > 0) { offer = new offer() { IdProduct = IdProduct }; } GetProducts(offer); return(View()); }
public void OfferVendor_GivenRequiredParameters_ShouldHaveRightProperties() { var offer = new offer(id: "12341", price: 16800, currencyId: CurrencyEnum.RUR, categoryId: 2, typePrefix: "Принтер", vendor: "HP", model: "Deskjet D2663"); var xOffer = new YmlSerializer().ToXDocument(offer).Root; xOffer.Should().NotBeNull(); xOffer.Should().HaveAttribute("id", "12341"); xOffer.Should().HaveAttribute("type", "vendor.model"); xOffer.Should().HaveElement("price").Which.Should().HaveValue("16800"); xOffer.Should().HaveElement("currencyId").Which.Should().HaveValue(CurrencyEnum.RUR.ToString()); xOffer.Should().HaveElement("categoryId").Which.Should().HaveValue(2.ToString()); xOffer.Should().HaveElement("typePrefix").Which.Should().HaveValue("Принтер"); xOffer.Should().HaveElement("vendor").Which.Should().HaveValue("HP"); xOffer.Should().HaveElement("model").Which.Should().HaveValue("Deskjet D2663"); }
public void GetProducts(offer offer = null) { IQueryable <product> products = db.product; if (offer != null && offer.product != null && offer.product.DeletionDatetime == null) { products = products.Where(p => p.DeletionDatetime == null); } if (!new CuponeraPrincipal(new CuponeraIdentity(User.Identity)).IsInRole("admin")) { products = products.Where(p => CuponeraIdentity.AdminCompany == p.store.IdCompany || CuponeraIdentity.CurrentAvaiableStores.Contains(p.IdStore)); } ViewBag.Products = products; ViewBag.IdProduct = new SelectList(products, "IdProduct", "Title", offer != null ? offer.IdProduct : 0); }
public ActionResult Saveoffer(string offername, string description, string offertype) { try { offer f = new offer(); f.offername = offername; f.description = description; f.offertype = offertype; db.offers.Add(f); db.SaveChanges(); ViewData["message"] = "Succesfully added"; } catch (Exception ex) { ViewData["message"] = ex.Message; } return(RedirectToAction("offers")); }
private bool Validate(offer offer) { if (offer.ExpirationDatetime.HasValue && offer.ExpirationDatetime <= offer.StartDatetime) { ModelState.AddModelError("Date", "Las fechas de expiración debe ser inferior a la de inicio."); GetProducts(offer); return(false); } if (db.offer.Where(o => !o.DeletionDatetime.HasValue && o.IdOffer != offer.IdOffer && (!o.ExpirationDatetime.HasValue || (o.ExpirationDatetime.HasValue && o.ExpirationDatetime < DateTime.Now && o.ExpirationDatetime > offer.StartDatetime)) && o.IdProduct == offer.IdProduct).Count() > 0) { ModelState.AddModelError("ServerValidations", "Existe otra oferta en curso, no puede haber mas de una oferta vigente para un producto."); GetProducts(offer); return(false); } return(true); }
public ActionResult UploadImg(int OfferId) { foreach (string file in Request.Files) { var postedFile = Request.Files[file]; int fileLenght = postedFile.ContentLength; var logopath = postedFile.FileName; //if (fileLenght <= 1048576) //{ Bitmap bmpUploadedImage = new Bitmap(postedFile.InputStream); Image objImage = IMGProcess.ScaleImageandSaveThumb(bmpUploadedImage, 500); objImage.Save(Server.MapPath("~/thumb/offers/") + logopath); //} offer thisoffer = db.Offers.Find(OfferId); thisoffer.thumb = logopath; db.Entry(thisoffer).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Edit", "Offers", new { Id = OfferId })); }
private async Task TapGestureRecognizer_TappedAsync(object sender, EventArgs e) { offer su = new offer { }; var xjson = JsonConvert.SerializeObject(su); var xcontent = new StringContent(xjson, Encoding.UTF8, "application/json"); HttpClient xclient = new HttpClient(); var xresult = await xclient.PostAsync("http://workshopksa.com/api/xofferts", xcontent); if (xresult.StatusCode == HttpStatusCode.Created) { await DisplayAlert("تنبيه!", "تم ارسال العرض للعميل", "استمرار"); } else { await DisplayAlert("تنبيه!", "توجد مشكلة تأكد من الاتصال بالانترنت او تواصل مع الدعم الفني", "موافق"); } }
public ActionResult Create([Bind(Include = "IdOffer,Title,StartDatetime,ExpirationDatetime,Description,IdProduct,Price")] offer offer, List <HttpPostedFileBase> fileUpload) { if (!Validate(offer)) { return(View(offer)); } if (!ValidateProductOffers(offer)) { GetProducts(offer); return(View(offer)); } if (ModelState.IsValid) { fileUpload = FilterFiles(fileUpload); string imagePath = null; HttpPostedFileBase fileImagePath; if (fileUpload.Count() == 1) { fileImagePath = fileUpload.FirstOrDefault(); fileUpload.RemoveAt(0); imagePath = GeneratePhisicalFile(fileImagePath); } offer.ImagePath = imagePath; offer.CreationDatetime = DateTime.Now; offer.ModificationDatetime = DateTime.Now; db.offer.Add(offer); db.SaveChanges(); //Save aditional images UploadImages(fileUpload, offer.IdOffer); return(RedirectToAction("Index")); } GetProducts(offer); return(View(offer)); }
/// <summary> /// Check for conflicting offers with recently accepted offer, and automatically decline them /// </summary> /// <param name="o">list of offers</param> /// <param name="a">recently accepted offer</param> protected void checkOffers(List <DBConnector> o, offer a) { if (a.returnState == offer.state.ACCEPTED) { foreach (DBConnector connect in o) { if (connect is offer) { offer c = connect as offer; if (c.returnState == offer.state.NOTHING) //If state is not set on offer { if (a.offerRoom.getId == c.offerRoom.getId && c.active(a.fNight, a.checkout)) { c.setState(offer.state.DECLINED); //Automatically decline if conflict is detected emailSender.sender.send(c.offerCust, "OFFER DECLINED", "Your offer to " + c.offerHotel.getName + " has been rejected."); } } } } } }
public FormOfferViewModel(offer offer, account cont) { _cont = cont; _offer = offer; OfferName = offer.offerName; Price = offer.newPrice.ToString(); NumberOfBookedRooms = offer.nrBookedRooms.ToString(); StartDate = DateTime.Parse(offer.startDate.ToString()); DueDate = DateTime.Parse(offer.dueDate.ToString()); actions = new OfferActions(); Visible = "Visible"; if (cont.userType == "Admin") { IsAdmin = "Visible"; } else { IsAdmin = "Hidden"; } }
// PUT: odata/offer(5) public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <offer> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } offer offer = await db.offer.FindAsync(key); if (offer == null) { return(NotFound()); } patch.Put(offer); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!offerExists(key)) { return(NotFound()); } else { throw; } } return(Updated(offer)); }
public HttpResponseMessage Get( string accesstoken, int offerid = -1, //<----------------- string offername = "", //<----------------- int serviceid = -1, //<----------------- string clientname = "", string requsetMassage = "", string response = "", string responseMassage = "", string desc = "", int mincost = 0, int maxcost = 0, int quantity = 0, bool requestable = true, Action action = Action.read) { try { Session u = Server.currentUser.FirstOrDefault(z => z.accessToken == accesstoken); if (u == null) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.Forbidden, "you must login")); } service s = Server.database.services.FirstOrDefault(x => x.service_id == serviceid); //<----------------- offer o = Server.database.offers.FirstOrDefault(x => x.offer_id == offerid); //<----------------- if (action == Action.create || action == Action.edit || action == Action.delete || action == Action.response) { if (u.user.user_details.type == UserType.user.ToString()) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.Forbidden, "you not allowed manage serivces and offers")); } if ((s != null && s.owner.username != u.user.username) || (o != null && o.service.owner.username != u.user.username)) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.Forbidden, "you are not owner of this service")); } if ((action == Action.create) && Server.database.offers.Select(z => z.name).Contains(offername)) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, "used name, try different name")); } } if (action != Action.create && o == null) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.NotFound, "offer not found")); } switch (action) { case Action.create: if (s == null) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.NotFound, "service not found")); } if (string.IsNullOrWhiteSpace(offername)) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, "offer name can't be empty")); } s.offers.Add( new offer() { name = offername, min_cost = mincost, max_cost = maxcost, quantity = quantity, requestable = requestable, description = desc, }); break; case Action.delete: Server.database.offers.Remove(o); // no need to check permission here, we already do break; case Action.edit: if (string.IsNullOrWhiteSpace(offername)) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, "offer name can't be empty")); } o.name = offername; o.min_cost = mincost; o.max_cost = maxcost; o.quantity = quantity; o.requestable = requestable; o.description = desc; break; case Action.read: return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { offerid = o.offer_id, offername = o.name, serviceid = o.service.service_id, servicename = o.service.name, username = o.service.owner.username, quantity = o.quantity ?? 0, maxcost = o.max_cost ?? 0, mixcost = o.min_cost ?? 0, desc = o.description ?? "", requestable = o.requestable ?? true, imgs = o.offer_images.Select(q => q.image), liked = u.user.offer_like.Contains(o), likecount = o.usersliked.Count, requestcount = o.requests.Count, requested = u.user != null && u.user.requests.Select(r => r.offer_id).Contains(o.offer_id) })); case Action.like: if (u.user.offer_like.Contains(o)) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, "you liked this offer already")); } u.user.offer_like.Add(o); break; case Action.unlike: if (!u.user.offer_like.Contains(o)) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, "you did not like this offer yet")); } u.user.offer_like.Remove(o); break; case Action.request: if (o.requests.FirstOrDefault(x => x.user.username == u.user.username) != null) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, "you requested this offer already")); } if (o.requestable != null && o.requestable == false) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.Forbidden, "this offer not Requstable now, try later")); } o.requests.Add(new request() { user = u.user, requsetMassage = requsetMassage, requestDate = DateTime.Now, }); break; case Action.unrequest: { request o2 = o.requests.FirstOrDefault(x => x.user.username == u.user.username); if (o2 == null) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, "you did not request this offer yet")); } o.requests.Remove(o2); } break; case Action.response: { request o2 = o.requests.FirstOrDefault(x => x.user.username == clientname); if (o2 == null) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, "this client did not request this offer")); } if (string.IsNullOrWhiteSpace(response)) { return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, "response can't be empty")); } o2.response = response; o2.responseMassage = responseMassage; o2.responseDate = DateTime.Now; } break; default: return(ControllerContext.Request.CreateResponse(HttpStatusCode.BadRequest, "bad action")); } Server.database.SaveChanges(); return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, "ok")); } catch (Exception ex) { Server.Loger(DateTime.Now + " - OfferController - " + ex.Message); return(ControllerContext.Request.CreateResponse(HttpStatusCode.InternalServerError, "Internal Error on server")); } }