public Operation <long> CreateService(ServiceModel model) { return(Operation.Create((Func <long>)(() => { var service = _db.Query <Service>().Where(s => s.ServiceId == model.ServiceId).FirstOrDefault(); if (service != null) { throw new Exception("Service is Created already"); } service = model.Create(); service.CreatedBy = model.UserId; service.CreatedOn = DateTime.Now; _db.Add <Service>(service); _db.SaveChanges().Unwrap(); return (long)service.ServiceId; }))); }
public bool CreateService(ServiceModel model) { //return System.Operation.Create(() => //{ var isExists = _context.Services.Where(c => c.ServId == model.ServId).FirstOrDefault(); if (isExists != null) { throw new Exception("user email already exist"); } var entity = model.Create(model); _context.Services.Add(entity); _context.SaveChanges(); return(true); //}); }