public d_notification GetDBobject(Guid idOwner) { d_notification dbItem = new d_notification { id = Id, message = Message, is_read = IsRead, id_owner = idOwner, }; return(dbItem); }
public void Save(d_notification dbItem) { if (dbItem.id == 0) //create { //penanggulangan data null if (context.d_notification.Count() > 0) { dbItem.id = context.d_notification.Max(n => n.id) + 1; } else { dbItem.id = 1; } context.d_notification.Add(dbItem); } else //edit { var entry = context.Entry(dbItem); entry.State = EntityState.Modified; } context.SaveChanges(); }
public void Delete(d_notification dbItem) { context.d_notification.Remove(dbItem); context.SaveChanges(); }
public string Add() { //kamus string code; Guid idOwner = new Guid("156c2cde-2c19-46c3-bcba-a27f9d1e4998"); owner owner = RepoOwner.FindByPk(idOwner); BookingFormStub bfs = new BookingFormStub(); Business.Infrastructure.FilterInfo filters = new Business.Infrastructure.FilterInfo { Filters = new List <Business.Infrastructure.FilterInfo> { new Business.Infrastructure.FilterInfo { Field = "name", Operator = "eq", Value = "Avanza" } }, Logic = "and" }; car_model cm; DateTime dtStart, dtFinish; DateTimeOffset dtoStart, dtoFinish; //algoritma code = RepoRent.GenerateRentCode(owner); bfs.IdCustomer = new Guid("54612b5e-611f-4b71-9dbd-ed35b6f2976b"); bfs.Code = code; bfs.PickupLocation = "Jl. Sudirman no. 16"; cm = RepoCarModel.Find(null, filters); if (cm != null) { bfs.IdCarModel = cm.id; } dtStart = new DateTime(2016, 6, 4, 8, 0, 0); dtStart = DateTime.SpecifyKind(dtStart, DateTimeKind.Local); dtoStart = dtStart; dtFinish = new DateTime(2016, 6, 4, 8, 0, 0); dtFinish = DateTime.SpecifyKind(dtFinish, DateTimeKind.Local); dtoFinish = dtFinish; bfs.StartRent = dtoStart; bfs.FinishRent = dtoFinish; bfs.Price = 300000; bfs.Status = RentStatus.NEW; //save rent rent dbItem = bfs.GetDbObjectOnCreate("dummy", idOwner); RepoRent.Save(dbItem); //save notification NotificationFormStub nfs = new NotificationFormStub(); nfs.Message = "Booking baru dari Citylink Cars"; nfs.IdOwner = idOwner; d_notification notif = nfs.GetDBobject(idOwner); RepoDummyNotification.Save(notif); return(new JavaScriptSerializer().Serialize(bfs)); }