public JsonResultEntity Create([FromBody] PlaceLocationEntity placelocationEntity) { PlaceLocationBL placelocationBL = new PlaceLocationBL(); JsonResultEntity response = new JsonResultEntity(); try { var result = placelocationBL.Create(placelocationEntity); if (result.HasWarning()) { response.Message = String.Join(",", result.Warning); return(response); } response.Success = true; response.Data = result.Value; } catch (Exception ex) { response.Message = ex.Message; LoggerHelper.Error(ex); } return(response); }
public PlaceLocationEntity Create(PlaceLocationEntity placelocationEntity) { var query = @"INSERT INTO ""PlaceLocation""(""PlaceName"",""Description"",""PlaceNote"",""IsVenue"",""Address1"",""Address2"",""City"",""State"",""Country"",""ZipPostal"",""Latitude"",""Longitude"",""Priority"",""CreatedDate"",""PlaceCategoryID"",""Phone"",""Weblink"",""Email"",""Slug"",""SubCategoryID"") VALUES(@PlaceName,@Description,@PlaceNote,@IsVenue,@Address1,@Address2,@City,@State,@Country,@ZipPostal,@Latitude,@Longitude,@Priority,@CreatedDate,@PlaceCategoryID,@Phone,@Weblink,@Email,@Slug,@SubCategoryID) RETURNING ""ID"";"; int id = DbConnection.Query <int>(query, placelocationEntity).Single(); placelocationEntity.ID = id; return(placelocationEntity); }
public int Update(PlaceLocationEntity placelocationEntity) { int affectedRows = 0; if (IsHaveId <PlaceLocationEntity>(placelocationEntity) == false) { var query = @"UPDATE ""PlaceLocation"" SET ""PlaceName""=@PlaceName,""Description""=@Description,""PlaceNote""=@PlaceNote,""IsVenue""=@IsVenue,""Address1""=@Address1,""Address2""=@Address2,""City""=@City,""State""=@State,""Country""=@Country,""ZipPostal""=@ZipPostal,""Latitude""=@Latitude,""Longitude""=@Longitude,""Priority""=@Priority,""ModifiedDate""=@ModifiedDate,""PlaceCategoryID""=@PlaceCategoryID,""Phone""=@Phone,""Weblink""=@Weblink,""Email""=@Email,""Slug""=@Slug,""SubCategoryID""=@SubCategoryID WHERE ""ID""=@ID"; affectedRows = DbConnection.Execute(query, placelocationEntity); } return(affectedRows); }
public ResultEntity <PlaceLocationEntity> Create(PlaceLocationEntity placelocationEntity) { var validationResult = new ResultEntity <PlaceLocationEntity>(); placelocationEntity.CreatedDate = DateTime.Now; using (var placelocationDA = new PlaceLocationDA()) { validationResult.Value = placelocationDA.Create(placelocationEntity); } return(validationResult); }
public ResultEntity <PlaceLocationEntity> Update(PlaceLocationEntity placelocationEntity) { var validationResult = new ResultEntity <PlaceLocationEntity>(); placelocationEntity.ModifiedDate = DateTime.Now; using (var placelocationDA = new PlaceLocationDA()) { var resultUpdate = placelocationDA.Update(placelocationEntity); if (resultUpdate <= 0) { validationResult.Warning.Add("Failed Updating PlaceLocation!"); return(validationResult); } validationResult.Value = placelocationEntity; } return(validationResult); }