public void CloseModelCreate() { if (ModelCreate == null) { return; } if (ModelCreate.IsEnabled) { ModelCreate.Close(); } }
public IHttpActionResult createShowHideProduct([FromBody] ModelCreate modelCreate) { Response response = new Response(); if (modelCreate.fromDate == null || modelCreate.endDate == null) { response.code = "400"; response.status = "chưa chọn khoản ngày tháng"; return(Content <Response>(System.Net.HttpStatusCode.OK, response)); } if (modelCreate.DaysOfWeek.Count == 0) { response.code = "400"; response.status = "chưa chọn thứ"; return(Content <Response>(System.Net.HttpStatusCode.OK, response)); } if (modelCreate.times.Count == 0) { response.code = "400"; response.status = "chưa chọn khoản giờ"; return(Content <Response>(System.Net.HttpStatusCode.OK, response)); } if (modelCreate.productId.Count == 0) { response.code = "400"; response.status = "chưa chọn sản phẩm"; return(Content <Response>(System.Net.HttpStatusCode.OK, response)); } foreach (var day in modelCreate.DaysOfWeek) { for (var i = 0; i < modelCreate.times.Count; i++) { var time = modelCreate.times[i]; foreach (var product in modelCreate.productId) { IEnumerable <ShowHideProduct> showHideProduct = Service.showHideDAO.findShowHideProducts(modelCreate.fromDate, modelCreate.endDate, day, time.fromTime, time.toTime, product, time.show); if (showHideProduct.Count() > 0) { response.code = "409"; response.status = "Sản phẩm này đã bị trùng lịch"; return(Content <Response>(System.Net.HttpStatusCode.OK, response)); } } } } foreach (var day in modelCreate.DaysOfWeek) { for (var i = 0; i < modelCreate.times.Count; i++) { var time = modelCreate.times[i]; ShowHideProduct create = new ShowHideProduct(); create.startDate = modelCreate.fromDate; create.endDate = modelCreate.endDate; create.dayOfWeek = day; create.fromTime = time.fromTime; create.toTime = time.toTime; create.show = time.show; foreach (var id in modelCreate.productId) { create.productId = id; Service.showHideDAO.insertShowHideProduct(create); } } } response.code = "200"; response.status = "Tạo lịch thành công"; return(Content <Response>(System.Net.HttpStatusCode.OK, response)); }
public ActionResult Create([Bind(Include = "SiglaExam,Nombre,Cedula,Email,NombreP,Apellido1,Apellido2,Descripcion")] ModelCreate modelCreate) { if (ModelState.IsValid) { var CedulaP = new SqlParameter("@CedulaP", modelCreate.Cedula); CedulaP.SqlDbType = SqlDbType.Char; CedulaP.Size = 9; var Email = new SqlParameter("@Email", string.IsNullOrEmpty(modelCreate.Email) ? DBNull.Value : (object)modelCreate.Email); Email.SqlDbType = SqlDbType.VarChar; Email.Size = 50; Email.IsNullable = true; var NombreP = new SqlParameter("@NombreP", string.IsNullOrEmpty(modelCreate.NombreP) ? DBNull.Value : (object)modelCreate.NombreP); NombreP.SqlDbType = SqlDbType.VarChar; NombreP.Size = 15; NombreP.IsNullable = true; var Apellido1 = new SqlParameter("@Apellido1", string.IsNullOrEmpty(modelCreate.Apellido1) ? DBNull.Value : (object)modelCreate.Apellido1); Apellido1.SqlDbType = SqlDbType.VarChar; Apellido1.Size = 15; Apellido1.IsNullable = true; var Apellido2 = new SqlParameter("@Apellido2", string.IsNullOrEmpty(modelCreate.Apellido2) ? DBNull.Value : (object)modelCreate.Apellido2); Apellido2.SqlDbType = SqlDbType.VarChar; Apellido2.Size = 15; Apellido2.IsNullable = true; var SiglaExam = new SqlParameter("@SiglaExam", modelCreate.SiglaExam); SiglaExam.SqlDbType = SqlDbType.Char; SiglaExam.Size = 5; var NombreE = new SqlParameter("@NombreE", string.IsNullOrEmpty(modelCreate.Nombre) ? DBNull.Value : (object)modelCreate.Nombre); NombreE.SqlDbType = SqlDbType.VarChar; NombreE.Size = 15; NombreE.IsNullable = true; var Descripcion = new SqlParameter("@Descripcion", string.IsNullOrEmpty(modelCreate.Descripcion) ? DBNull.Value : (object)modelCreate.Descripcion); Descripcion.SqlDbType = SqlDbType.VarChar; Descripcion.Size = 50; Descripcion.IsNullable = true; var NumeroError = new SqlParameter("@NumeroError", 0); NumeroError.Direction = ParameterDirection.Output; NumeroError.SqlDbType = SqlDbType.Int; bool error = false; try { db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, "EXEC Aplicar_Examen_Sin_Transaccion @CedulaP, @Email, @NombreP, @Apellido1, @Apellido2, @SiglaExam, @NombreE, @Descripcion, @NumeroError OUTPUT", CedulaP, Email, NombreP, Apellido1, Apellido2, SiglaExam, NombreE, Descripcion, NumeroError); } catch { error = true; } //Caso donde hay error sin transacciones(no usa try en bd) if (error) { TempData["Error"] = -1; } else { TempData["Error"] = Convert.ToInt32(NumeroError.Value); } return(RedirectToAction("Index")); } ViewBag.Cedula = new SelectList(db.Profesor_Transacciones, "Cedula", "Cedula", modelCreate.Cedula); ViewBag.SiglaExam = new SelectList(db.Examen_Transacciones, "SiglaExam", "SiglaExam", modelCreate.SiglaExam); return(View(modelCreate)); }