/// <summary> /// database connection for Update Excisting entry /// </summary> /// <param name="ParkingID">Primary key</param> /// <param name="data">Update data</param> /// <returns></returns> public int UpdateParkingDetail(int ParkingID, UpdateParking data) { try { SqlConnection connection = DatabaseConnection(); //for store procedure and connection to database SqlCommand command = StoreProcedureConnection("spUpdateParkingdetails", connection); command.Parameters.Add("@ParkingID", SqlDbType.Int).Value = ParkingID; command.Parameters.AddWithValue("@ParkingStatus", data.ParkingStatus); command.Parameters.AddWithValue("@ExitTime", data.ExitTime); connection.Open(); int Response = command.ExecuteNonQuery(); connection.Close(); if (Response == 0) { return(0); } else { return(1); } } catch (Exception e) { throw new Exception(e.Message); } }
/// <summary> /// API for Update Excisting entry /// </summary> /// <param name="ParkingID">Primary key</param> /// <param name="data">Update data</param> /// <returns></returns> public int UpdateParkingDetail(int ParkingID, UpdateParking data) { try { var result = _ParkingRepository.UpdateParkingDetail(ParkingID, data); return(result); } catch (Exception e) { throw new Exception(e.Message); } }
public ActionResult UpdateParkingDetail([FromRoute] int ParkingID, [FromBody] UpdateParking Info) { try { var response = BusinessLayer.UpdateParkingDetail(ParkingID, Info); if (!response.Equals(null)) { var Status = "Success"; var Message = "Employee Data Updated Sucessfully"; return(this.Ok(new { Status, Message, data = Info })); } else { var status = "Unsuccess"; var Message = "Employee Data not Updated"; return(this.BadRequest(new { status, Message, data = Info })); } } catch (Exception exception) { return(BadRequest(new { error = exception.Message })); } }