public ActionResult CreateAuction(AuctionEventModel AEM) { AEM.AuctionMainPicture = "-__-"; AEM.AuctionID = 0; AEM.TotalProducts = 0; if (ModelState.IsValid) { string fileName = Path.GetFileNameWithoutExtension(AEM.ImageFile.FileName); string extension = Path.GetExtension(AEM.ImageFile.FileName); fileName = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() + extension; AEM.AuctionMainPicture = "~/img/upload/auction/" + fileName; fileName = Path.Combine(Server.MapPath("~/img/upload/auction/"), fileName); AEM.ImageFile.SaveAs(fileName); AEM.StartTime = dateTimeCorrection(AEM.StartTime); AEM.StartTime = dateTimeCorrection(AEM.EndTime); int row = AuctionProccessor.createAuction(AEM.AuctionTitle, AEM.AuctionDescription, AEM.StartTime, AEM.EndTime, AEM.TotalProducts, AEM.AuctionStatus, AEM.AuctionMainPicture); } return(View()); }
public static int CreateAuction(string title, string description, string startTime, string endTime, int totalProducts, string status, string mainPic) { AuctionEventModel data = new AuctionEventModel { auctionTitle = title, auctionDescription = description, StartTime = startTime, EndTime = endTime, totalProduct = totalProducts, auctionStatus = status, auctionMainPicture = mainPic }; string sql = @"INSERT INTO dbo.AuctionEvent (AuctionTitle, Description, StartTime, EndTime, TotalProducts, AuctionStatus, AuctionMainPicture) VALUES(@title, @description, @startTime, @endTime, @totalProducts, @status, @mainPic)"; return(SqlDataAccess.SaveData(sql, data)); }