public async Task <ServiceMerchant> Update(ServiceMerchant serviceMerchant, int id) { using (IDbConnection db = new SqlConnection(ConnectionString)) { var result = await db.QuerySingleOrDefaultAsync <ServiceMerchant>(@" UPDATE [dbo].[ServiceMerchant] SET [ServiceId] = @ServiceId ,[MerchantId] = @MerchantId ,[AppId] = @AppId ,[TRId] = @TRId ,[RelationshipName] = @RelationshipName ,[Status] = @Status OUTPUT Inserted.[ServiceId] ,Inserted.[MerchantId] ,Inserted.[AppId] ,Inserted.[TRId] ,Inserted.[RelationshipName] ,Inserted.[Status] WHERE Id = @Id", new { ServiceId = serviceMerchant.ServiceId, MerchantId = serviceMerchant.MerchantId, AppId = serviceMerchant.AppId, TRId = serviceMerchant.TRId, RelationshipName = serviceMerchant.RelationshipName, Status = serviceMerchant.Status, Id = id }); return(result); } }
public async Task <IActionResult> Create(ServiceMerchantViewModel serviceMerchantModel) { var service = await _serviceRepository.Get(serviceMerchantModel.ServiceId); var serviceMerchant = await _merchantRepository.Get(serviceMerchantModel.MerchantId); if (service != null && serviceMerchant != null) { ServiceMerchant newServiceMerchant = new ServiceMerchant() { AppId = serviceMerchantModel.AppId, TRId = serviceMerchantModel.TRId, RelationshipName = serviceMerchantModel.RelationshipName, Status = serviceMerchantModel.Status, Created = DateTime.UtcNow, ServiceId = service.Id, MerchantId = serviceMerchant.Id, Updated = null }; await _serviceMerchantRepository.Insert(newServiceMerchant); } return(RedirectToAction("List")); }
public async Task <ServiceMerchant> Insert(ServiceMerchant serviceMerchant) { using (IDbConnection db = new SqlConnection(ConnectionString)) { var result = await db.QuerySingleOrDefaultAsync <ServiceMerchant>(@" INSERT INTO [dbo].[ServiceMerchant] ([ServiceId] ,[MerchantId] ,[AppId] ,[TRId] ,[RelationshipName] ,[Status] ,[Created] ,[Updated]) OUTPUT Inserted.[ServiceId] ,Inserted.[MerchantId] ,Inserted.[AppId] ,Inserted.[TRId] ,Inserted.[RelationshipName] ,Inserted.[Status] ,Inserted.[Created] ,Inserted.[Updated] VALUES (@ServiceId ,@MerchantId ,@AppId ,@TRId ,@RelationshipName ,@Status ,@Created ,@Updated)", new { ServiceId = serviceMerchant.ServiceId, MerchantId = serviceMerchant.MerchantId, AppId = serviceMerchant.AppId, TRId = serviceMerchant.TRId, RelationshipName = serviceMerchant.RelationshipName, Status = serviceMerchant.Status, Created = serviceMerchant.Created, Updated = serviceMerchant.Updated }); return(result); } }
public async Task <IActionResult> Edit(EditServiceMerchantViewModel serviceMerchantModel, int id) { if (ModelState.IsValid) { ServiceMerchant serviceMerchant = new ServiceMerchant() { ServiceId = serviceMerchantModel.ServiceId, MerchantId = serviceMerchantModel.MerchantId, AppId = serviceMerchantModel.AppId, TRId = serviceMerchantModel.TRId, RelationshipName = serviceMerchantModel.RelationshipName, Status = serviceMerchantModel.Status, }; await _serviceMerchantRepository.Update(serviceMerchant, id); } return(RedirectToAction("List")); }