public JsonResult InsertOrUpdateZone(ZoneVM _obj) { try { _obj.createdBy = Convert.ToInt32(Session["userId"]); int result = _zoneDA.InsertOrUpdateZone(_obj); if (_obj.zoneId == 0) { return(Json(new { success = true, message = "Data Saved" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = true, message = "Data Updated" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { if (ex.Message.Contains("Violation of UNIQUE KEY")) { return(Json(new { success = false, message = "Zone with this name Already Exists!!" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public IActionResult PostZone([FromForm] ZoneVM zonevm) { var Zone = ZoneServises.ZoneAdded(zonevm); if (Zone == null) { return(NotFound()); } return(Ok(Zone)); }
public HttpResponseMessage ClearZone(Guid inventorization, [FromBody] ZoneVM zone) { try { inventorizationDomain.ClearZone(inventorization, zone.ZoneId); } catch (Exception ex) { _logger.Error(ex, $"Zone clearing error. Zone: {zone.ZoneId}. InventorizationId: {inventorization}"); } return(Request.CreateResponse(HttpStatusCode.OK, new { Result = "Ok" })); }
public int InsertOrUpdateZone(ZoneVM _obj) { int result = 0; using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("isp_zone", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@zoneId", _obj.zoneId); cmd.Parameters.AddWithValue("@zoneName", _obj.zoneName); cmd.Parameters.AddWithValue("@isActive", _obj.isActive); cmd.Parameters.AddWithValue("@createdBy", _obj.createdBy); result = 1; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } return(result); }
public HttpResponseMessage CloseZone(Guid inventorization, [FromBody] ZoneVM zone) { try { ZoneState state = _inventorizationRepository.GetZoneState(inventorization, zone.ZoneId); if (state != null) { var userClaims = Request.GetOwinContext().Authentication.User; _inventorizationRepository.CloseZone(state, Guid.Parse(userClaims.Claims.Single(x => x.Type == ClaimTypes.Sid).Value)); return(Request.CreateResponse(HttpStatusCode.OK, new { Result = "Ok" })); } return(Request.CreateResponse(HttpStatusCode.Forbidden, new { Result = "Error", Reason = "Зона не была открыта" })); } catch (Exception ex) { _logger.Error(ex, $"Open zone error. Zone: {zone.ZoneId}. InventorizationId: {inventorization}"); } return(Request.CreateResponse(HttpStatusCode.OK, new { Result = "Ok" })); }
public ZoneVM GetZoneById(int zoneId) { ZoneVM _obj = new ZoneVM(); using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("gsp_getZoneById", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@zoneId", zoneId); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { _obj.zoneId = Convert.ToInt16(rdr["zoneId"]); _obj.zoneName = rdr["zoneName"].ToString(); _obj.isActive = Convert.ToBoolean(rdr["isActive"]); } con.Close(); } return(_obj); }
public Zone ZoneAdded(ZoneVM Zonevm) { Zone Zone = new Zone(); Zone.Name = Zonevm.Name; Zone.NumberOfRooms = Zonevm.NumberOfRooms; Zone.Place = Zonevm.Place; Zone.Available = Zonevm.Available; Zone.Capacity = Zonevm.Capacity; if (Zonevm.ImageUrl != null) { Zone.ImageUrl = fileUploadService.upload(Zonevm.ImageUrl); } //else add a profile avatar image ZoneMainOperation.Insert(Zone); ZoneMainOperation.Save(); return(Zone); }
public Zone ZoneEdited(ZoneVM Zonevm) { Zone Zone = ZoneMainOperation.GetById(Zonevm.ID); if (Zone != null) { Zone.Name = Zonevm.Name; Zone.NumberOfRooms = Zonevm.NumberOfRooms; Zone.Place = Zonevm.Place; Zone.Available = Zonevm.Available; Zone.Capacity = Zonevm.Capacity; if (Zonevm.ImageUrl != null) { Zone.ImageUrl = fileUploadService.upload(Zonevm.ImageUrl); } //else add a profile avatar image ZoneMainOperation.Update(Zone); ZoneMainOperation.Save(); } return(Zone); }