// GET: ApplicationTypes public Object FreezingFacilityPost([FromBody] FreezingFacilityInput ff) { string sJSONResponse = ""; DataTable dt_AppType = new DataTable(); string ServerDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); int a = 0; string olPackage_Query = ""; FreezingFacilityOutput ffopt = new FreezingFacilityOutput(); try { cnn.Open(); olPackage_Query = "insert into FreezingFacility(BranchCode,SMFMID,FreezingName,NoOfDays,FreezingStartDate,FreezingExpireDate,CreatedBy,CreatedOn,IsDeleted,IsActive) values('" + ff.BranchCode + "','" + ff.SMFMID + "','" + ff.FreezingName + "','" + ff.NoOfDays + "','" + ff.FreezingStartDate + "','" + ff.FreezingExpireDate + "','" + ff.CreatedBy + "','" + ServerDateTime + "',0,1) SELECT @@IDENTITY;"; SqlCommand tm_cmd = new SqlCommand(olPackage_Query, cnn); a = Convert.ToInt32(tm_cmd.ExecuteScalar()); ffopt.status = "Success"; ffopt.value = a; } catch (Exception ex) { ffopt.status = "Fail"; } finally { cnn.Close(); } sJSONResponse = JsonConvert.SerializeObject(ffopt); return(sJSONResponse); }
public Object FreezingFacilityDelete([FromBody] FreezingFacilityInput ff) { string sJSONResponse = ""; FreezingFacilityOutput ffopt = new FreezingFacilityOutput(); SqlCommand command = cnn.CreateCommand(); string ServerDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); try { cnn.Close(); cnn.Open(); SqlTransaction transaction; transaction = cnn.BeginTransaction("SampleTransaction"); command.Connection = cnn; command.Transaction = transaction; try { command.CommandText = "delete from FreezingFacility where ID=" + ff.ID + " "; command.ExecuteNonQuery(); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); ffopt.status = "fail"; ffopt.value = 1; } finally { ffopt.status = "success"; ffopt.value = 1; } } catch (Exception ec) { } sJSONResponse = JsonConvert.SerializeObject(ffopt); return(sJSONResponse); }