public void CreateGuitarTestIncorrect() { var model = new Guitars(); model.Id = 0; model.Name = "Guitar Test"; model.BodyID = 1; model.NeckID = 1; model.BridgeID = 1; model.PickupID = 1; model.StartDate = Convert.ToDateTime("01/10/2017"); model.PaintDate = Convert.ToDateTime("01/10/2017"); model.TestDate = Convert.ToDateTime("01/10/2017"); model.FinishDate = Convert.ToDateTime("01/10/2017"); var repository = Substitute.For<IGuitarRepositorio>(); var service = new GuitarService(repository); try { service.Create(model); Assert.Fail("the validation is not complete"); } catch (ApplicationException ex) { } //Assert repository.DidNotReceive().Create(model); }
public void Create(Guitars Model) { var Fecha1 = Model.StartDate; var Fecha2 = Model.PaintDate; var Fecha3 = Model.TestDate; var Fecha4 = Model.FinishDate; if (Fecha1 == Fecha2 && Fecha2 == Fecha3 && Fecha3 == Fecha4) { throw new ApplicationException( string.Format("This dates are invalid, they are all the same!!")); } this.GuitarRepositorio.Create(Model); }
public void CreateGuitarTest() { var model = new Guitars(); model.Id = 1; model.Name = "Guitar Test"; model.BodyID = 1; model.NeckID = 1; model.BridgeID = 1; model.PickupID = 1; model.StartDate = Convert.ToDateTime("01/10/2017"); model.PaintDate = Convert.ToDateTime("10/10/2017"); model.TestDate = Convert.ToDateTime("15/10/2017"); model.FinishDate = Convert.ToDateTime("27/10/2017"); var repository = Substitute.For<IGuitarRepositorio>(); var service = new GuitarService(repository); service.Create(model); //Assert repository.Received().Create(model); }
public void Update(Guitars Model) { var context = new GuitarDbContext(); context.Entry(Model).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public Guitars GetOneGuitar(int id) { IEnumerable<Guitars> result = new List<Guitars>(); Guitars res = new Guitars(); using (var con = new SqlConnection(this.ConnectionString)) { con.Open(); var p = new DynamicParameters(); p.Add("@xId", id); result = con.Query<Guitars>("GetOneGuitar", p, commandType: System.Data.CommandType.StoredProcedure); con.Close(); } res = result.FirstOrDefault(); return res; }
public void Update(Guitars Model) { this.GuitarRepositorio.Update(Model); }
public void UpdateGuitar(Guitars model, FormCollection formcollection) { var guitar = this.GuitarService.GetOneGuitar(model.Id); guitar.Id = model.Id; guitar.StartDate = model.StartDate; guitar.PaintDate = model.PaintDate; guitar.TestDate = model.TestDate; guitar.FinishDate = model.FinishDate; try { var operation = formcollection["oper"]; switch (operation) { case "edit": this.GuitarService.Update(guitar); break; default: break; } } catch (Exception ex) { Response.Write(ex.Message); } }