public async Task <IHttpActionResult> UpdateWarehouseSection([FromBody] WarehouseSection value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } using (TransactionScope scope = new TransactionScope()) using (var connection = new SqlConnection(sqlConnectionString)) { connection.Open(); var categoryType = new WarehouseSection() { WarehouseID = value.WarehouseID, Section = value.Section, SubSection = value.SubSection, Row = value.Row, Col = value.Col, Drawers = value.Drawers, ID = value.ID }; string updateQuery = @"UPDATE tblSection SET WarehouseID = @WarehouseID,Section=@Section,SubSection = @SubSection, Row= @Row, Col= @Col, Drawers= @Drawers WHERE ID = @ID"; var result = connection.Execute(updateQuery, categoryType); scope.Complete(); return(Json(new { Message = "Record Updated Successfully" })); } }
public async Task <IHttpActionResult> AddWarehouseSection([FromBody] WarehouseSection warehouseSection) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } using (var connection = new SqlConnection(sqlConnectionString)) { connection.Open(); var p = new WarehouseSection { WarehouseID = warehouseSection.ID, Row = warehouseSection.Row, Addedon = DateTime.Now, Section = warehouseSection.Section, SubSection = warehouseSection.SubSection, Col = warehouseSection.Col, Drawers = warehouseSection.Drawers }; p.ID = connection.Query <int>(@"insert tblSection(WarehouseID,Row,Addedon,Section,SubSection,Col,Drawers) values (@WarehouseID,@Row,@Addedon,@Section,@SubSection,@Col,@Drawers) select cast(scope_identity() as int)", p).First(); return(Json(new { Message = "Record Inserted Successfully" })); } }
public dynamic GetByWarehouseSectionId(int Id) { var warehouseSection = new WarehouseSection(); var connection = new SqlConnection(sqlConnectionString); warehouseSection = connection.Query <WarehouseSection>("Select * from tblSection where ID = @Id", new { Id = Id }).FirstOrDefault(); return(warehouseSection); }
public static void SetSection(WarehouseSection section) { ActiveSection = section; }