public async Task <ValueEntity> Update(Guid id, ValueEntity item) { using (var context = new FormsEntities()) { var entity = context.Values.Find(id); entity.ModifiedDateTime = DateTime.Now; context.SaveChanges(); return(entity); } }
public static ValueViewModel ToViewModel(this ValueEntity item) { var model = new ValueViewModel() { Id = item.Id, CreatedDateTime = item.CreatedDateTime, FormId = item.FormId, IsSent = item.IsSent, Latitude = item.Latitude, Longitude = item.Longitude, ModifiedDateTime = item.ModifiedDateTime, SyncDateTime = item.SyncDateTime, UserId = item.UserId }; return(model); }
public async Task <ValueEntity> Create(ValueEntity item) { using (var context = new FormsEntities()) { if (item.Id == null || item.Id == Guid.Empty) { item.Id = Guid.NewGuid(); } else { item.Id = new Guid(item.Id.ToString()); } item.CreatedDateTime = DateTime.Now; context.Values.Add(item); context.SaveChanges(); return(item); } }