/// <summary> /// Create a service. /// </summary> /// <param name="serviceId">Id of service.</param> /// <param name="name">Name of service.</param> /// <param name="description">Description of service.</param> /// <param name="charge">Charge of service.</param> /// <param name="data">Image of service.</param> public void CreateService(Guid serviceId, String name, String description, String charge, String data) { try { Service service = new Service(); service.Service_Id = serviceId; service.Service_Name = name; service.Service_Description = description; service.Service_Charge = SecurityHelper.Instance.EncryptCryptography(charge, true); service.Service_Image = data; // Check name if (SD.GetService(service.Service_Name) != null) throw new Exception(String.Format("This service with the name is '{0}' has already existed.", service.Service_Name)); int result = SD.Create(service); if (result == -1) { throw new Exception("An error occurred while executing this operation."); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Create new a service /// </summary> /// <param name="service">Service that you want to create.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public int Create(Service service) { return DBHelper.Instance.Insert(service); }
/// <summary> /// Update a service. /// </summary> /// <param name="service">The service that be updated.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public int Update(Service service) { return DBHelper.Instance.Update(service, String.Format("Service_Id = '{0}'", service.Service_Id)); }